diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 11 | ||||
-rw-r--r-- | src/nvim/msgpack_rpc/channel.c | 11 | ||||
-rw-r--r-- | src/nvim/os/event.c | 1 | ||||
-rw-r--r-- | src/nvim/os/signal.c | 16 | ||||
-rw-r--r-- | src/nvim/os/wstream.c | 26 |
5 files changed, 13 insertions, 52 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 7e020a9bce..67cef68b38 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -21,8 +21,6 @@ #include <math.h> #include <limits.h> -#include "nvim/lib/klist.h" - #include "nvim/assert.h" #include "nvim/vim.h" #include "nvim/ascii.h" @@ -469,9 +467,6 @@ typedef struct { list_T *received; int status; } JobEvent; -#define JobEventFreer(x) -KMEMPOOL_INIT(JobEventPool, JobEvent, JobEventFreer) -static kmempool_t(JobEventPool) *job_event_pool = NULL; static int disable_job_defer = 0; /* @@ -508,8 +503,6 @@ void eval_init(void) set_vim_var_nr(VV_SEARCHFORWARD, 1L); set_vim_var_nr(VV_HLSEARCH, 1L); set_reg_var(0); /* default for v:register is not 0 but '"' */ - - job_event_pool = kmp_init(JobEventPool); } #if defined(EXITFREE) @@ -20149,7 +20142,7 @@ static inline bool is_user_job(Job *job) static inline void push_job_event(Job *job, ufunc_T *callback, const char *type, char *data, size_t count, int status) { - JobEvent *event_data = kmp_alloc(JobEventPool, job_event_pool); + JobEvent *event_data = xmalloc(sizeof(JobEvent)); event_data->received = NULL; if (data) { event_data->received = list_alloc(); @@ -20317,7 +20310,7 @@ end: // exit event, safe to free job data now term_job_data_decref(ev->data); } - kmp_free(JobEventPool, job_event_pool, ev); + free(ev); } static void script_host_eval(char *name, typval_T *argvars, typval_T *rettv) diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 35549ce042..34879e425e 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -5,8 +5,6 @@ #include <uv.h> #include <msgpack.h> -#include "nvim/lib/klist.h" - #include "nvim/api/private/helpers.h" #include "nvim/api/vim.h" #include "nvim/msgpack_rpc/channel.h" @@ -69,10 +67,6 @@ typedef struct { uint64_t request_id; } RequestEvent; -#define _noop(x) -KMEMPOOL_INIT(RequestEventPool, RequestEvent, _noop) -static kmempool_t(RequestEventPool) *request_event_pool = NULL; - static uint64_t next_id = 1; static PMap(uint64_t) *channels = NULL; static PMap(cstr_t) *event_strings = NULL; @@ -85,7 +79,6 @@ static msgpack_sbuffer out_buffer; /// Initializes the module void channel_init(void) { - request_event_pool = kmp_init(RequestEventPool); channels = pmap_new(uint64_t)(); event_strings = pmap_new(cstr_t)(); msgpack_sbuffer_init(&out_buffer); @@ -455,7 +448,7 @@ static void handle_request(Channel *channel, msgpack_object *request) Array args = ARRAY_DICT_INIT; msgpack_rpc_to_array(request->via.array.ptr + 3, &args); bool defer = (!kv_size(channel->call_stack) && handler.defer); - RequestEvent *event_data = kmp_alloc(RequestEventPool, request_event_pool); + RequestEvent *event_data = xmalloc(sizeof(RequestEvent)); event_data->channel = channel; event_data->handler = handler; event_data->args = args; @@ -487,7 +480,7 @@ static void on_request_event(Event event) // All arguments were freed already, but we still need to free the array free(args.items); decref(channel); - kmp_free(RequestEventPool, request_event_pool, e); + free(e); } static bool channel_write(Channel *channel, WBuffer *buffer) diff --git a/src/nvim/os/event.c b/src/nvim/os/event.c index dbb9d337cf..0560da1e2e 100644 --- a/src/nvim/os/event.c +++ b/src/nvim/os/event.c @@ -46,7 +46,6 @@ void event_init(void) // early msgpack-rpc initialization msgpack_rpc_init_method_table(); msgpack_rpc_helpers_init(); - wstream_init(); // Initialize input events input_init(); // Timer to wake the event loop if a timeout argument is passed to diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c index a332ad2314..f824543003 100644 --- a/src/nvim/os/signal.c +++ b/src/nvim/os/signal.c @@ -1,9 +1,8 @@ +#include <assert.h> #include <stdbool.h> #include <uv.h> -#include "nvim/lib/klist.h" - #include "nvim/ascii.h" #include "nvim/vim.h" #include "nvim/globals.h" @@ -15,10 +14,6 @@ #include "nvim/os/signal.h" #include "nvim/os/event.h" -#define SignalEventFreer(x) -KMEMPOOL_INIT(SignalEventPool, int, SignalEventFreer) -kmempool_t(SignalEventPool) *signal_event_pool = NULL; - static uv_signal_t spipe, shup, squit, sterm; #ifdef SIGPWR static uv_signal_t spwr; @@ -32,7 +27,6 @@ static bool rejecting_deadly; void signal_init(void) { - signal_event_pool = kmp_init(SignalEventPool); uv_signal_init(uv_default_loop(), &spipe); uv_signal_init(uv_default_loop(), &shup); uv_signal_init(uv_default_loop(), &squit); @@ -119,18 +113,16 @@ static void deadly_signal(int signum) static void signal_cb(uv_signal_t *handle, int signum) { - int *n = kmp_alloc(SignalEventPool, signal_event_pool); - *n = signum; + assert(signum >= 0); event_push((Event) { .handler = on_signal_event, - .data = n + .data = (void *)(uintptr_t)signum }, false); } static void on_signal_event(Event event) { - int signum = *((int *)event.data); - kmp_free(SignalEventPool, signal_event_pool, event.data); + int signum = (int)(uintptr_t)event.data; switch (signum) { #ifdef SIGPWR diff --git a/src/nvim/os/wstream.c b/src/nvim/os/wstream.c index 13c6c0429f..ad9d936625 100644 --- a/src/nvim/os/wstream.c +++ b/src/nvim/os/wstream.c @@ -5,8 +5,6 @@ #include <uv.h> -#include "nvim/lib/klist.h" - #include "nvim/os/uv_helpers.h" #include "nvim/os/wstream.h" #include "nvim/os/wstream_defs.h" @@ -41,24 +39,10 @@ typedef struct { uv_write_t uv_req; } WRequest; -#define WRequestFreer(x) -KMEMPOOL_INIT(WRequestPool, WRequest, WRequestFreer) -kmempool_t(WRequestPool) *wrequest_pool = NULL; -#define WBufferFreer(x) -KMEMPOOL_INIT(WBufferPool, WBuffer, WBufferFreer) -kmempool_t(WBufferPool) *wbuffer_pool = NULL; - #ifdef INCLUDE_GENERATED_DECLARATIONS # include "os/wstream.c.generated.h" #endif -/// Initialize pools for reusing commonly created objects -void wstream_init(void) -{ - wrequest_pool = kmp_init(WRequestPool); - wbuffer_pool = kmp_init(WBufferPool); -} - /// Creates a new WStream instance. A WStream encapsulates all the boilerplate /// necessary for writing to a libuv stream. /// @@ -163,7 +147,7 @@ bool wstream_write(WStream *wstream, WBuffer *buffer) wstream->curmem += buffer->size; - WRequest *data = kmp_alloc(WRequestPool, wrequest_pool); + WRequest *data = xmalloc(sizeof(WRequest)); data->wstream = wstream; data->buffer = buffer; data->uv_req.data = data; @@ -173,7 +157,7 @@ bool wstream_write(WStream *wstream, WBuffer *buffer) uvbuf.len = buffer->size; if (uv_write(&data->uv_req, wstream->stream, &uvbuf, 1, write_cb)) { - kmp_free(WRequestPool, wrequest_pool, data); + free(data); goto err; } @@ -202,7 +186,7 @@ WBuffer *wstream_new_buffer(char *data, size_t refcount, wbuffer_data_finalizer cb) { - WBuffer *rv = kmp_alloc(WBufferPool, wbuffer_pool); + WBuffer *rv = xmalloc(sizeof(WBuffer)); rv->size = size; rv->refcount = refcount; rv->cb = cb; @@ -236,7 +220,7 @@ static void write_cb(uv_write_t *req, int status) } } - kmp_free(WRequestPool, wrequest_pool, data); + free(data); } void wstream_release_wbuffer(WBuffer *buffer) @@ -246,7 +230,7 @@ void wstream_release_wbuffer(WBuffer *buffer) buffer->cb(buffer->data); } - kmp_free(WBufferPool, wbuffer_pool, buffer); + free(buffer); } } |