From b5640b136caf6e85337fab5309446a999419f6cb Mon Sep 17 00:00:00 2001 From: Nicolas Hillegeer Date: Fri, 30 May 2014 16:56:45 +0200 Subject: 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). --- src/nvim/os/msgpack_rpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/os/msgpack_rpc.c b/src/nvim/os/msgpack_rpc.c index 423c5d584d..932a7717fd 100644 --- a/src/nvim/os/msgpack_rpc.c +++ b/src/nvim/os/msgpack_rpc.c @@ -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; } -- cgit