mirror of
https://github.com/neovim/neovim.git
synced 2025-10-09 03:16:31 +00:00
memory: Add free
wrapper and refactor project to use it
We already use wrappers for allocation, the new `xfree` function is the equivalent for deallocation and provides a way to fully replace the malloc implementation used by Neovim.
This commit is contained in:
@@ -478,9 +478,9 @@ static void on_request_event(Event event)
|
||||
result,
|
||||
&out_buffer));
|
||||
// All arguments were freed already, but we still need to free the array
|
||||
free(args.items);
|
||||
xfree(args.items);
|
||||
decref(channel);
|
||||
free(e);
|
||||
xfree(e);
|
||||
}
|
||||
|
||||
static bool channel_write(Channel *channel, WBuffer *buffer)
|
||||
@@ -601,7 +601,7 @@ static void unsubscribe(Channel *channel, char *event)
|
||||
|
||||
// Since the string is no longer used by other channels, release it's memory
|
||||
pmap_del(cstr_t)(event_strings, event_string);
|
||||
free(event_string);
|
||||
xfree(event_string);
|
||||
}
|
||||
|
||||
/// Close the channel streams/job and free the channel resources.
|
||||
@@ -655,13 +655,13 @@ static void free_channel(Channel *channel)
|
||||
pmap_free(cstr_t)(channel->subscribed_events);
|
||||
kv_destroy(channel->call_stack);
|
||||
kv_destroy(channel->delayed_notifications);
|
||||
free(channel);
|
||||
xfree(channel);
|
||||
}
|
||||
|
||||
static void close_cb(uv_handle_t *handle)
|
||||
{
|
||||
free(handle->data);
|
||||
free(handle);
|
||||
xfree(handle->data);
|
||||
xfree(handle);
|
||||
}
|
||||
|
||||
static Channel *register_channel(void)
|
||||
@@ -738,7 +738,7 @@ static WBuffer *serialize_request(uint64_t channel_id,
|
||||
WBuffer *rv = wstream_new_buffer(xmemdup(sbuffer->data, sbuffer->size),
|
||||
sbuffer->size,
|
||||
refcount,
|
||||
free);
|
||||
xfree);
|
||||
msgpack_sbuffer_clear(sbuffer);
|
||||
api_free_array(args);
|
||||
return rv;
|
||||
@@ -757,7 +757,7 @@ static WBuffer *serialize_response(uint64_t channel_id,
|
||||
WBuffer *rv = wstream_new_buffer(xmemdup(sbuffer->data, sbuffer->size),
|
||||
sbuffer->size,
|
||||
1, // responses only go though 1 channel
|
||||
free);
|
||||
xfree);
|
||||
msgpack_sbuffer_clear(sbuffer);
|
||||
api_free_object(arg);
|
||||
return rv;
|
||||
|
Reference in New Issue
Block a user