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.
git-archimport-id: srvx@srvx.net--2005-srvx/srvx--devo--1.3--patch-6
# arch-tag: automatic-ChangeLog--srvx@srvx.net--2005-srvx/srvx--devo--1.3
#
+2005-01-21 15:10:49 GMT Michael Poole <mdpoole@troilus.org> 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 <mdpoole@troilus.org> patch-5
Summary:
#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' };
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;
}
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;