Skip to content

Commit

Permalink
Define an allocator for run requests
Browse files Browse the repository at this point in the history
Comparing the size of the binary before and after this change, shows
that the size does not increase when -02 is used.
  • Loading branch information
jonas committed Feb 18, 2009
1 parent 6bd4d0f commit 7f8f12b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tig.c
Expand Up @@ -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)
{
Expand All @@ -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;
Expand Down

0 comments on commit 7f8f12b

Please sign in to comment.