From 7f8f12b6ce7e30df211e1143e8e297b16f7ed961 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Wed, 18 Feb 2009 12:09:12 +0100 Subject: [PATCH] Define an allocator for run requests Comparing the size of the binary before and after this change, shows that the size does not increase when -02 is used. --- tig.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tig.c b/tig.c index 16b0df2..5acb398 100644 --- a/tig.c +++ b/tig.c @@ -1325,6 +1325,8 @@ struct run_request { static struct run_request *run_request; static size_t run_requests; +DEFINE_ALLOCATOR(realloc_run_requests, struct run_request, 8) + static enum request add_run_request(enum keymap keymap, int key, int argc, const char **argv) { @@ -1333,11 +1335,9 @@ add_run_request(enum keymap keymap, int key, int argc, const char **argv) if (argc >= ARRAY_SIZE(req->argv) - 1) return REQ_NONE; - req = realloc(run_request, (run_requests + 1) * sizeof(*run_request)); - if (!req) + if (!realloc_run_requests(&run_request, run_requests, 1)) return REQ_NONE; - run_request = req; req = &run_request[run_requests]; req->keymap = keymap; req->key = key; -- 2.30.2