mirror of
https://github.com/neovim/neovim.git
synced 2025-10-15 14:26:07 +00:00
msgpack: NULL terminate incoming strings
It's a 1-byte loss of memory but it allows us to skip copying and NULL-terminating strings when interacting with vim functions that accept C strings. This lowers the pressure on the allocator and saves lines of code (no more dup/free pairs).
This commit is contained in:
@@ -163,7 +163,7 @@ bool msgpack_rpc_to_string(msgpack_object *obj, String *arg)
|
||||
return false;
|
||||
}
|
||||
|
||||
arg->data = xmemdup(obj->via.raw.ptr, obj->via.raw.size);
|
||||
arg->data = xmemdupz(obj->via.raw.ptr, obj->via.raw.size);
|
||||
arg->size = obj->via.raw.size;
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user