Skip to content

Commit

Permalink
reduce allocation by a factor of 4
Browse files Browse the repository at this point in the history
unit8_t instead of size_t reduces memory allocation to more appropriate
block size

credit @jnicholls
nanomsg/nanomsg#363 (comment)
  • Loading branch information
reqshark committed Feb 3, 2015
1 parent b00ca38 commit 0d71ee4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions utils/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void *nn_alloc_ (size_t size, const char *name)
{
uint8_t *chunk;

chunk = calloc (sizeof (struct nn_alloc_hdr) + size, sizeof(size_t));
chunk = calloc (sizeof (struct nn_alloc_hdr) + size, sizeof(uint8_t));
if (!chunk)
return NULL;

Expand Down Expand Up @@ -131,7 +131,7 @@ void nn_alloc_term (void)

void *nn_alloc_ (size_t size)
{
return calloc (size, sizeof(size_t));
return calloc (size, sizeof(uint8_t));
}

void *nn_realloc (void *ptr, size_t size)
Expand Down

0 comments on commit 0d71ee4

Please sign in to comment.