#define DISPOSE(point) \
do \
{ \
if (!(point)) \
{ \
bugf( "Freeing null pointer %s:%d", __FILE__, __LINE__ ); \
fprintf( stderr, "DISPOSEing NULL in %s, line %d\n", __FILE__, __LINE__ ); \
} \
else free(point); \
point = NULL; \
} while(0)
#
#define IS_IN_HASH( what, what_type, next, orderby, hash, hash_size, result ) \
#
do \
#
{ \
#
int __iHash = (orderby)%(hash_size); \
#
(result) = false; \
#
for ( what_type *__what = (hash)[__iHash]; __what; __what = __what->next ) \
#
if ( __what == (what) ) \
#
(result) = true; \
#
} while(0);
#
#define REMOVE_FROM_HASH( what, what_type, next, orderby, hash, hash_size ) \
#
do \
#
{ \
#
int __iHash = (orderby)%(hash_size); \
#
if ( (what) == (hash)[__iHash] ) \
#
(hash)[__iHash] = (what)->next; \
#
else \
#
{ \
#
for ( what_type *__what = (hash)[__iHash]; __what; __what = __what->next ) \
#
if ( __what->next == (what) ) \
#
__what->next = (what)->next; \
#
} \
#
} while(0);
The problem is for some reason alloc_mem has been replaced with alloc_perm (via CREATE macro?). Now you cannot just free the memory allocated with alloc_perm because it's a block pointed by others on a list. In fact free() should never be called from ROM's free_mem() for blocks allocated via alloc_perm(), free_mem() just puts them back on the free list.
Now I don't know from whence the CREATE and DISPOSE macros come from. They are not native to ROM stock code. Clearly there's some misuse here as alloc_perm() is apparently called under the covers. Perhaps the macros were created for a different mud?