Skip to content

Commit

Permalink
Re-add commented out capacity check
Browse files Browse the repository at this point in the history
  • Loading branch information
noib3 committed Jan 2, 2025
1 parent a101287 commit f7b29d3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/types/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@ impl StringBuilder {

/// Initialize [`StringBuilder`] with capacity.
pub fn with_capacity(cap: usize) -> Self {
// Neovim uses `xstrdup` to clone strings, which doesn't support null
// pointers.
//
// For more infos, see https://github.com/noib3/nvim-oxi/pull/211#issuecomment-2566960494
//
// if cap == 0 {
// return Self::new();
// }
let real_cap = cap + 1;
let ptr = unsafe { libc::malloc(real_cap) };
if ptr.is_null() {
Expand Down

0 comments on commit f7b29d3

Please sign in to comment.