From: Jonas Fonseca Date: Wed, 18 Feb 2009 11:09:12 +0000 (+0100) Subject: Define an allocator for run requests X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7f8f12b6ce7e30df211e1143e8e297b16f7ed961;p=tig.git 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. --- 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;