[srvx-commits] commit: More debug allocator fixes and enhancements
Brought to you by:
entrope
From: Michael P. <md...@tr...> - 2005-01-21 15:15:09
|
Revision: srvx--devo--1.3--patch-6 Archive: sr...@sr...--2005-srvx Creator: Michael Poole <md...@tr...> Date: Fri Jan 21 10:10:49 EST 2005 Standard-date: 2005-01-21 15:10:49 GMT Modified-files: ChangeLog src/alloc-srvx.c src/dict-splay.c New-patches: sr...@sr...--2005-srvx/srvx--devo--1.3--patch-6 Summary: More debug allocator fixes and enhancements Keywords: src/alloc-srvx.c (*_MAGIC): ASk recognized the CCSDS ASM sequence. (srvx_free): Overwrite with 0xDE bytes to distinguish from uninitialized values. As SailorFrag suggested, only overwrite the user region. src/dict-splay.c (dict_insert): Check whether free functions need to be worked around here as well. * added files {arch}/srvx/srvx--devo/srvx--devo--1.3/sr...@sr...--2005-srvx/patch-log/patch-6 * modified files --- orig/ChangeLog +++ mod/ChangeLog @@ -2,6 +2,25 @@ # arch-tag: aut...@sr...--2005-srvx/srvx--devo--1.3 # +2005-01-21 15:10:49 GMT Michael Poole <md...@tr...> patch-6 + + Summary: + More debug allocator fixes and enhancements + Revision: + srvx--devo--1.3--patch-6 + + src/alloc-srvx.c (*_MAGIC): ASk recognized the CCSDS ASM sequence. + (srvx_free): Overwrite with 0xDE bytes to distinguish from + uninitialized values. As SailorFrag suggested, only overwrite the + user region. + + src/dict-splay.c (dict_insert): Check whether free functions need to + be worked around here as well. + + modified files: + ChangeLog src/alloc-srvx.c src/dict-splay.c + + 2005-01-21 00:48:35 GMT Michael Poole <md...@tr...> patch-5 Summary: --- orig/src/alloc-srvx.c +++ mod/src/alloc-srvx.c @@ -19,7 +19,6 @@ #undef malloc #undef free -/* cookies for anybody who recognizes these bytes without help :) */ #define ALLOC_MAGIC 0x1acf #define FREE_MAGIC 0xfc1d const char redzone[] = { '\x03', '\x47', '\x76', '\xc7' }; @@ -132,11 +131,11 @@ block = (struct alloc_header *)ptr - 1; assert(block->magic == ALLOC_MAGIC); assert(0 == memcmp((char*)(block + 1) + block->size, redzone, sizeof(redzone))); - size = block->size + sizeof(*block); - memset(block, 0, size); + size = block->size; + memset(block + 1, 0xde, size); block->magic = FREE_MAGIC; free(block); alloc_count--; - alloc_size -= size - sizeof(*block); + alloc_size -= size; (void)file; (void)line; } --- orig/src/dict-splay.c +++ mod/src/dict-splay.c @@ -186,8 +186,18 @@ dict->root = new_node; } else { /* maybe we don't want to overwrite it .. oh well */ - if (dict->free_data) dict->free_data(dict->root->data); - if (dict->free_keys) dict->free_keys((void*)dict->root->key); + if (dict->free_data) { + if (dict->free_data == free) + free(dict->root->data); + else + dict->free_data(dict->root->data); + } + if (dict->free_keys) { + if (dict->free_keys == free) + free((void*)dict->root->key); + else + dict->free_keys((void*)dict->root->key); + } free(new_node); dict->root->key = key; dict->root->data = data; |