diff options
author | Frederic Culot <calcurse@culot.org> | 2009-01-03 21:32:10 +0000 |
---|---|---|
committer | Frederic Culot <calcurse@culot.org> | 2009-01-03 21:32:10 +0000 |
commit | 936b6fe3737c760657d82c50fa6b81c3011ffa27 (patch) | |
tree | cb909cd269419fdf31134ecc407315765804e7c1 /src/mem.c | |
parent | bf3bce0ab2d6d5fc8448821fbfa29b48a1bb5994 (diff) | |
download | calcurse-936b6fe3737c760657d82c50fa6b81c3011ffa27.zip |
more code cleanup
Diffstat (limited to 'src/mem.c')
-rw-r--r-- | src/mem.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -1,4 +1,4 @@ -/* $calcurse: mem.c,v 1.2 2009/01/02 19:52:32 culot Exp $ */ +/* $calcurse: mem.c,v 1.3 2009/01/03 21:32:11 culot Exp $ */ /* * Calcurse - text-based organizer @@ -149,7 +149,7 @@ dbg_calloc (size_t nmemb, size_t size, const char *pos) void * dbg_realloc (void *ptr, size_t size, const char *pos) { - unsigned *buf, old_size; + unsigned *buf, old_size, cpy_size; if (size == 0 || ptr == 0) return (void *)0; @@ -158,12 +158,12 @@ dbg_realloc (void *ptr, size_t size, const char *pos) return (void *)0; old_size = *((unsigned *)ptr - EXTRA_SPACE_START + BLK_SIZE); - bcopy (ptr, buf + EXTRA_SPACE_START, old_size); + cpy_size = (old_size > size) ? size : old_size; + bcopy (ptr, buf, cpy_size); + mem_free (ptr); - mstats.nalloc += size; - - return (void *)(buf + EXTRA_SPACE_START); + return (void *)buf; } char * |