diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2015-04-12 11:37:22 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2015-04-13 08:22:44 -0300 |
commit | 34c48aaf123ffd8aec31b79f0b4d16d9a63fe59b (patch) | |
tree | 3342c6d4a1cc54bbadb6018725410117885b3517 /src/nvim/msgpack_rpc | |
parent | ba10e311bddab18e38b1b706e232f804c2da9174 (diff) | |
download | rneovim-34c48aaf123ffd8aec31b79f0b4d16d9a63fe59b.tar.gz rneovim-34c48aaf123ffd8aec31b79f0b4d16d9a63fe59b.tar.bz2 rneovim-34c48aaf123ffd8aec31b79f0b4d16d9a63fe59b.zip |
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.
Diffstat (limited to 'src/nvim/msgpack_rpc')
-rw-r--r-- | src/nvim/msgpack_rpc/channel.c | 16 | ||||
-rw-r--r-- | src/nvim/msgpack_rpc/remote_ui.c | 4 | ||||
-rw-r--r-- | src/nvim/msgpack_rpc/server.c | 6 |
3 files changed, 13 insertions, 13 deletions
diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 34879e425e..fc0409e137 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -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; diff --git a/src/nvim/msgpack_rpc/remote_ui.c b/src/nvim/msgpack_rpc/remote_ui.c index b554d76bed..07d78dd9d7 100644 --- a/src/nvim/msgpack_rpc/remote_ui.c +++ b/src/nvim/msgpack_rpc/remote_ui.c @@ -48,9 +48,9 @@ void remote_ui_disconnect(uint64_t channel_id) // destroy pending screen updates api_free_array(data->buffer); pmap_del(uint64_t)(connected_uis, channel_id); - free(ui->data); + xfree(ui->data); ui_detach(ui); - free(ui); + xfree(ui); } static Object remote_ui_attach(uint64_t channel_id, uint64_t request_id, diff --git a/src/nvim/msgpack_rpc/server.c b/src/nvim/msgpack_rpc/server.c index 91aca0c37a..c03531ca0c 100644 --- a/src/nvim/msgpack_rpc/server.c +++ b/src/nvim/msgpack_rpc/server.c @@ -57,7 +57,7 @@ bool server_init(void) if (!os_getenv(LISTEN_ADDRESS_ENV_VAR)) { char *listen_address = (char *)vim_tempname(); os_setenv(LISTEN_ADDRESS_ENV_VAR, listen_address, 1); - free(listen_address); + xfree(listen_address); } return server_start((char *)os_getenv(LISTEN_ADDRESS_ENV_VAR)) == 0; @@ -256,10 +256,10 @@ static void connection_cb(uv_stream_t *server, int status) static void free_client(uv_handle_t *handle) { - free(handle); + xfree(handle); } static void free_server(uv_handle_t *handle) { - free(handle->data); + xfree(handle->data); } |