mirror of
https://github.com/adtools/clib2.git
synced 2026-05-03 18:56:04 +00:00
The memory debugging code now places the the damage detection areas which bracket the allocation area so that the originally requested allocation size is used, not the rounded-up size. Debug output in memory node checking no longer counts the non-breaking space character as unprintable.
This commit is contained in:
@@ -59,18 +59,18 @@ get_hex_char(int n)
|
||||
{
|
||||
char result;
|
||||
|
||||
if(0 <= n && n <= 9)
|
||||
if (0 <= n && n <= 9)
|
||||
result = n + '0';
|
||||
else
|
||||
result = n + 'A' - 10;
|
||||
|
||||
return(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
STATIC VOID
|
||||
int_to_hex(unsigned long v,char * buffer,int min_digits)
|
||||
int_to_hex(unsigned long v, char * buffer, int min_digits)
|
||||
{
|
||||
int i,j,c;
|
||||
int i, j, c;
|
||||
|
||||
i = 0;
|
||||
|
||||
@@ -81,12 +81,12 @@ int_to_hex(unsigned long v,char * buffer,int min_digits)
|
||||
|
||||
buffer[i++] = get_hex_char(c);
|
||||
}
|
||||
while(v > 0);
|
||||
while (v > 0);
|
||||
|
||||
while(i < min_digits)
|
||||
while (i < min_digits)
|
||||
buffer[i++] = '0';
|
||||
|
||||
for(j = 0 ; j < i / 2 ; j++)
|
||||
for (j = 0 ; j < i / 2 ; j++)
|
||||
{
|
||||
c = buffer[i - 1 - j];
|
||||
buffer[i - 1 - j] = buffer[j];
|
||||
@@ -97,47 +97,47 @@ int_to_hex(unsigned long v,char * buffer,int min_digits)
|
||||
}
|
||||
|
||||
STATIC VOID
|
||||
dump_memory(unsigned char * m,int size,int ignore)
|
||||
dump_memory(const unsigned char * m, int size, int ignore)
|
||||
{
|
||||
const int mod = 20;
|
||||
int position,i,c;
|
||||
int position, i, c;
|
||||
char buffer[120];
|
||||
char hex[10];
|
||||
|
||||
buffer[0] = '\0';
|
||||
|
||||
for(i = 0 ; i < size ; i++)
|
||||
for (i = 0 ; i < size ; i++)
|
||||
{
|
||||
position = i % mod;
|
||||
if(position == 0)
|
||||
if (position == 0)
|
||||
{
|
||||
if(buffer[0] != '\0')
|
||||
if (buffer[0] != '\0')
|
||||
{
|
||||
int len = sizeof(buffer)-1;
|
||||
|
||||
while(len > 0 && buffer[len-1] == ' ')
|
||||
while (len > 0 && buffer[len-1] == ' ')
|
||||
len--;
|
||||
|
||||
buffer[len] = '\0';
|
||||
|
||||
kprintf("[%s] %s\n",__program_name,buffer);
|
||||
kprintf("[%s] %s\n", __program_name, buffer);
|
||||
}
|
||||
|
||||
memset(buffer,' ',sizeof(buffer)-1);
|
||||
memset(buffer, ' ', sizeof(buffer)-1);
|
||||
|
||||
int_to_hex((unsigned long)&m[i],hex,8);
|
||||
int_to_hex((unsigned long)&m[i], hex, 8);
|
||||
|
||||
memmove(buffer,hex,8);
|
||||
memmove(buffer, hex, 8);
|
||||
hex[9] = ':';
|
||||
}
|
||||
|
||||
if(m[i] != ignore)
|
||||
if (m[i] != ignore)
|
||||
{
|
||||
buffer[10 + 2 * position + 0] = get_hex_char(m[i] >> 4);
|
||||
buffer[10 + 2 * position + 1] = get_hex_char(m[i] & 15);
|
||||
|
||||
c = m[i];
|
||||
if(c < ' ' || (c >= 127 && c <= 160))
|
||||
if (c < ' ' || (127 <= c && c < 160))
|
||||
c = '.';
|
||||
|
||||
buffer[10 + 2 * mod + 1 + position] = c;
|
||||
@@ -149,111 +149,111 @@ dump_memory(unsigned char * m,int size,int ignore)
|
||||
}
|
||||
}
|
||||
|
||||
if(buffer[0] != '\0')
|
||||
if (buffer[0] != '\0')
|
||||
{
|
||||
int len = sizeof(buffer)-1;
|
||||
|
||||
while(len > 0 && buffer[len-1] == ' ')
|
||||
while (len > 0 && buffer[len-1] == ' ')
|
||||
len--;
|
||||
|
||||
buffer[len] = '\0';
|
||||
|
||||
kprintf("[%s] %s\n",__program_name,buffer);
|
||||
kprintf("[%s] %s\n", __program_name, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
STATIC VOID
|
||||
check_memory_node(struct MemoryNode * mn,const char * file,int line)
|
||||
check_memory_node(struct MemoryNode * mn, const char * file, int line)
|
||||
{
|
||||
ULONG size = GET_MN_SIZE(mn);
|
||||
unsigned char * head = (unsigned char *)(mn + 1);
|
||||
unsigned char * body = head + MALLOC_HEAD_SIZE;
|
||||
unsigned char * tail = body + size;
|
||||
ULONG size = mn->mn_OriginalSize;
|
||||
const unsigned char * head = (unsigned char *)&mn[1];
|
||||
const unsigned char * body = &head[MALLOC_HEAD_SIZE];
|
||||
const unsigned char * tail = &body[size];
|
||||
int max_head_damage = 0;
|
||||
int max_tail_damage = 0;
|
||||
int max_body_damage = 0;
|
||||
int i;
|
||||
|
||||
for(i = 1 ; i <= MALLOC_HEAD_SIZE ; i++)
|
||||
for (i = 1 ; i <= MALLOC_HEAD_SIZE ; i++)
|
||||
{
|
||||
if(head[MALLOC_HEAD_SIZE - i] != MALLOC_HEAD_FILL)
|
||||
if (head[MALLOC_HEAD_SIZE - i] != MALLOC_HEAD_FILL)
|
||||
max_head_damage = i;
|
||||
}
|
||||
|
||||
if(max_head_damage > 0)
|
||||
if (max_head_damage > 0)
|
||||
{
|
||||
kprintf("[%s] ",__program_name);
|
||||
kprintf("[%s] ", __program_name);
|
||||
|
||||
if(file != NULL)
|
||||
kprintf("%s:%ld:",file,line);
|
||||
if (file != NULL)
|
||||
kprintf("%s:%ld:", file, line);
|
||||
|
||||
kprintf("At least %ld bytes were damaged in front of allocation 0x%08lx..0x%08lx, size = %ld",
|
||||
max_head_damage,
|
||||
body,body + size - 1,size);
|
||||
body, body + size - 1, size);
|
||||
|
||||
if(mn->mn_File != NULL)
|
||||
kprintf(", allocated at %s:%ld",mn->mn_File,mn->mn_Line);
|
||||
if (mn->mn_File != NULL)
|
||||
kprintf(", allocated at %s:%ld", mn->mn_File, mn->mn_Line);
|
||||
|
||||
kprintf("\n");
|
||||
|
||||
dump_memory(head,MALLOC_HEAD_SIZE,MALLOC_HEAD_FILL);
|
||||
dump_memory(head, MALLOC_HEAD_SIZE, MALLOC_HEAD_FILL);
|
||||
}
|
||||
|
||||
for(i = 0 ; i < MALLOC_TAIL_SIZE ; i++)
|
||||
for (i = 0 ; i < MALLOC_TAIL_SIZE ; i++)
|
||||
{
|
||||
if(tail[i] != MALLOC_TAIL_FILL)
|
||||
if (tail[i] != MALLOC_TAIL_FILL)
|
||||
max_tail_damage = i+1;
|
||||
}
|
||||
|
||||
if(max_tail_damage > 0)
|
||||
if (max_tail_damage > 0)
|
||||
{
|
||||
kprintf("[%s] ",__program_name);
|
||||
kprintf("[%s] ", __program_name);
|
||||
|
||||
if(file != NULL)
|
||||
kprintf("%s:%ld:",file,line);
|
||||
if (file != NULL)
|
||||
kprintf("%s:%ld:", file, line);
|
||||
|
||||
kprintf("At least %ld bytes were damaged behind allocation 0x%08lx..0x%08lx, size = %ld (with damage = %ld)",
|
||||
max_tail_damage,
|
||||
body,body + size - 1,
|
||||
size,size+max_tail_damage);
|
||||
body, body + size - 1,
|
||||
size, size + max_tail_damage);
|
||||
|
||||
if(mn->mn_File != NULL)
|
||||
kprintf(", allocated at %s:%ld",mn->mn_File,mn->mn_Line);
|
||||
if (mn->mn_File != NULL)
|
||||
kprintf(", allocated at %s:%ld", mn->mn_File, mn->mn_Line);
|
||||
|
||||
kprintf("\n");
|
||||
|
||||
dump_memory(tail,MALLOC_TAIL_SIZE,MALLOC_TAIL_FILL);
|
||||
dump_memory(tail, MALLOC_TAIL_SIZE, MALLOC_TAIL_FILL);
|
||||
}
|
||||
|
||||
if(mn->mn_AlreadyFree)
|
||||
if (mn->mn_AlreadyFree)
|
||||
{
|
||||
ULONG j;
|
||||
|
||||
for(j = 0 ; j < size ; j++)
|
||||
for (j = 0 ; j < size ; j++)
|
||||
{
|
||||
if(body[j] != MALLOC_FREE_FILL)
|
||||
if (body[j] != MALLOC_FREE_FILL)
|
||||
max_body_damage = j+1;
|
||||
}
|
||||
|
||||
if(max_body_damage > 0)
|
||||
if (max_body_damage > 0)
|
||||
{
|
||||
kprintf("[%s] ",__program_name);
|
||||
kprintf("[%s] ", __program_name);
|
||||
|
||||
if(file != NULL)
|
||||
kprintf("%s:%ld:",file,line);
|
||||
if (file != NULL)
|
||||
kprintf("%s:%ld:", file, line);
|
||||
|
||||
kprintf("At least %ld bytes were damaged in freed allocation 0x%08lx..0x%08lx, size = %ld",
|
||||
max_body_damage,
|
||||
body,body + size - 1,size);
|
||||
body, body + size - 1, size);
|
||||
|
||||
if(mn->mn_File != NULL)
|
||||
kprintf(", allocated at %s:%ld",mn->mn_File,mn->mn_Line);
|
||||
if (mn->mn_File != NULL)
|
||||
kprintf(", allocated at %s:%ld", mn->mn_File, mn->mn_Line);
|
||||
|
||||
kprintf("\n");
|
||||
|
||||
dump_memory(body,size,MALLOC_FREE_FILL);
|
||||
dump_memory(body, size, MALLOC_FREE_FILL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -261,17 +261,17 @@ check_memory_node(struct MemoryNode * mn,const char * file,int line)
|
||||
/****************************************************************************/
|
||||
|
||||
void
|
||||
__check_memory_allocations(const char * file,int line)
|
||||
__check_memory_allocations(const char * file, int line)
|
||||
{
|
||||
struct MemoryNode * mn;
|
||||
|
||||
__memory_lock();
|
||||
|
||||
for(mn = (struct MemoryNode *)__memory_list.mlh_Head ;
|
||||
for (mn = (struct MemoryNode *)__memory_list.mlh_Head ;
|
||||
mn->mn_MinNode.mln_Succ != NULL ;
|
||||
mn = (struct MemoryNode *)mn->mn_MinNode.mln_Succ)
|
||||
{
|
||||
check_memory_node(mn,file,line);
|
||||
check_memory_node(mn, file, line);
|
||||
}
|
||||
|
||||
__memory_unlock();
|
||||
@@ -290,7 +290,7 @@ __find_memory_node(void * address)
|
||||
|
||||
#if defined(__USE_MEM_TREES)
|
||||
{
|
||||
result = __red_black_tree_find(&__memory_tree,address);
|
||||
result = __red_black_tree_find(&__memory_tree, address);
|
||||
}
|
||||
#else
|
||||
{
|
||||
@@ -298,11 +298,11 @@ __find_memory_node(void * address)
|
||||
|
||||
result = NULL;
|
||||
|
||||
for(mn = (struct MemoryNode *)__memory_list.mlh_Head ;
|
||||
for (mn = (struct MemoryNode *)__memory_list.mlh_Head ;
|
||||
mn->mn_MinNode.mln_Succ != NULL ;
|
||||
mn = (struct MemoryNode *)mn->mn_MinNode.mln_Succ)
|
||||
{
|
||||
if(address == mn->mn_Allocation)
|
||||
if (address == mn->mn_Allocation)
|
||||
{
|
||||
result = mn;
|
||||
break;
|
||||
@@ -331,7 +331,7 @@ __find_memory_node(void * address)
|
||||
|
||||
result = &((struct MemoryNode *)address)[-1];
|
||||
|
||||
return(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
@@ -349,96 +349,84 @@ remove_and_free_memory_node(struct MemoryNode * mn)
|
||||
|
||||
__memory_lock();
|
||||
|
||||
allocation_size = mn->mn_AllocationSize;
|
||||
|
||||
#if defined(__MEM_DEBUG)
|
||||
{
|
||||
Remove((struct Node *)mn);
|
||||
|
||||
#if defined(__USE_MEM_TREES)
|
||||
{
|
||||
__red_black_tree_remove(&__memory_tree,mn);
|
||||
__red_black_tree_remove(&__memory_tree, mn);
|
||||
}
|
||||
#endif /* __USE_MEM_TREES */
|
||||
|
||||
allocation_size = sizeof(*mn) + MALLOC_HEAD_SIZE + GET_MN_SIZE(mn) + MALLOC_TAIL_SIZE;
|
||||
|
||||
assert( allocation_size == mn->mn_AllocationSize );
|
||||
|
||||
memset(mn,MALLOC_FREE_FILL,allocation_size);
|
||||
}
|
||||
#else
|
||||
{
|
||||
allocation_size = sizeof(*mn) + GET_MN_SIZE(mn);
|
||||
memset(mn, MALLOC_FREE_FILL, allocation_size);
|
||||
}
|
||||
#endif /* __MEM_DEBUG */
|
||||
|
||||
#if defined(__USE_SLAB_ALLOCATOR)
|
||||
{
|
||||
/* Are we using the slab allocator? */
|
||||
if(__slab_data.sd_InUse)
|
||||
if (__slab_data.sd_InUse)
|
||||
{
|
||||
__slab_free(mn,allocation_size);
|
||||
/* No need to remove the memory node because it was never
|
||||
* added or has already been removed if the memory debugging
|
||||
* option is in effect.
|
||||
*/
|
||||
__slab_free(mn, allocation_size);
|
||||
}
|
||||
/* Are we using the memory pool? */
|
||||
else if (__memory_pool != NULL)
|
||||
{
|
||||
/* No need to remove the memory node because it was never
|
||||
* added or has already been removed if the memory debugging
|
||||
* option is in effect.
|
||||
*/
|
||||
PROFILE_OFF();
|
||||
FreePooled(__memory_pool, mn, allocation_size);
|
||||
PROFILE_ON();
|
||||
}
|
||||
/* So we have to do this the hard way... */
|
||||
else
|
||||
{
|
||||
if(__memory_pool != NULL)
|
||||
#if NOT defined(__MEM_DEBUG)
|
||||
{
|
||||
PROFILE_OFF();
|
||||
FreePooled(__memory_pool,mn,allocation_size);
|
||||
PROFILE_ON();
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(__MEM_DEBUG)
|
||||
{
|
||||
PROFILE_OFF();
|
||||
FreeMem(mn,allocation_size);
|
||||
PROFILE_ON();
|
||||
}
|
||||
#else
|
||||
{
|
||||
struct MinNode * mln = (struct MinNode *)mn;
|
||||
|
||||
mln--;
|
||||
|
||||
Remove((struct Node *)mln);
|
||||
|
||||
PROFILE_OFF();
|
||||
FreeMem(mln,sizeof(*mln) + allocation_size);
|
||||
PROFILE_ON();
|
||||
Remove((struct Node *)mn);
|
||||
}
|
||||
#endif /* __MEM_DEBUG */
|
||||
}
|
||||
|
||||
PROFILE_OFF();
|
||||
FreeMem(mn, allocation_size);
|
||||
PROFILE_ON();
|
||||
}
|
||||
}
|
||||
#else
|
||||
{
|
||||
if(__memory_pool != NULL)
|
||||
if (__memory_pool != NULL)
|
||||
{
|
||||
/* No need to remove the memory node because it was never
|
||||
* added or has already been removed if the memory debugging
|
||||
* option is in effect.
|
||||
*/
|
||||
PROFILE_OFF();
|
||||
FreePooled(__memory_pool,mn,allocation_size);
|
||||
FreePooled(__memory_pool, mn, allocation_size);
|
||||
PROFILE_ON();
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(__MEM_DEBUG)
|
||||
#if NOT defined(__MEM_DEBUG)
|
||||
{
|
||||
PROFILE_OFF();
|
||||
FreeMem(mn,allocation_size);
|
||||
PROFILE_ON();
|
||||
}
|
||||
#else
|
||||
{
|
||||
struct MinNode * mln = (struct MinNode *)mn;
|
||||
|
||||
mln--;
|
||||
|
||||
Remove((struct Node *)mln);
|
||||
|
||||
PROFILE_OFF();
|
||||
FreeMem(mln,sizeof(*mln) + allocation_size);
|
||||
PROFILE_ON();
|
||||
Remove((struct Node *)mn);
|
||||
}
|
||||
#endif /* __MEM_DEBUG */
|
||||
|
||||
/* No need to remove the memory node because the memory
|
||||
* debugging option is in effect.
|
||||
*/
|
||||
PROFILE_OFF();
|
||||
FreeMem(mn, allocation_size);
|
||||
PROFILE_ON();
|
||||
}
|
||||
}
|
||||
#endif /* __USE_SLAB_ALLOCATOR */
|
||||
@@ -452,37 +440,35 @@ remove_and_free_memory_node(struct MemoryNode * mn)
|
||||
/****************************************************************************/
|
||||
|
||||
void
|
||||
__free_memory_node(struct MemoryNode * mn,const char * UNUSED file,int UNUSED line)
|
||||
__free_memory_node(struct MemoryNode * mn, const char * UNUSED file, int UNUSED line)
|
||||
{
|
||||
assert(mn != NULL);
|
||||
|
||||
#ifdef __MEM_DEBUG
|
||||
{
|
||||
ULONG size = GET_MN_SIZE(mn);
|
||||
check_memory_node(mn, file, line);
|
||||
|
||||
check_memory_node(mn,file,line);
|
||||
|
||||
if(NOT mn->mn_AlreadyFree)
|
||||
if (NOT mn->mn_AlreadyFree)
|
||||
{
|
||||
#ifdef __MEM_DEBUG_LOG
|
||||
{
|
||||
kprintf("[%s] - %10ld 0x%08lx [",__program_name,size,mn->mn_Allocation);
|
||||
kprintf("[%s] - %10ld 0x%08lx [",__program_name, mn->mn_OriginalSize, mn->mn_Allocation);
|
||||
|
||||
if(mn->mn_File != NULL)
|
||||
kprintf("allocated at %s:%ld, ",mn->mn_File,mn->mn_Line);
|
||||
if (mn->mn_File != NULL)
|
||||
kprintf("allocated at %s:%ld, ", mn->mn_File, mn->mn_Line);
|
||||
|
||||
kprintf("freed at %s:%ld]\n",file,line);
|
||||
kprintf("freed at %s:%ld]\n", file, line);
|
||||
}
|
||||
#endif /* __MEM_DEBUG_LOG */
|
||||
|
||||
if(__never_free)
|
||||
if (__never_free)
|
||||
{
|
||||
mn->mn_AlreadyFree = TRUE;
|
||||
|
||||
mn->mn_FreeFile = (char *)file;
|
||||
mn->mn_FreeLine = line;
|
||||
|
||||
memset(mn->mn_Allocation,MALLOC_FREE_FILL,size);
|
||||
memset(&mn[1], MALLOC_FREE_FILL, MALLOC_HEAD_SIZE + mn->mn_OriginalSize + MALLOC_TAIL_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -493,19 +479,19 @@ __free_memory_node(struct MemoryNode * mn,const char * UNUSED file,int UNUSED li
|
||||
{
|
||||
#ifdef __MEM_DEBUG_LOG
|
||||
{
|
||||
kprintf("[%s] - %10ld 0x%08lx [",__program_name,size,mn->mn_Allocation);
|
||||
kprintf("[%s] - %10ld 0x%08lx [", __program_name, mn->mn_AllocationSize, mn);
|
||||
|
||||
kprintf("FAILED]\n");
|
||||
}
|
||||
#endif /* __MEM_DEBUG_LOG */
|
||||
|
||||
kprintf("[%s] %s:%ld:Allocation at address 0x%08lx, size %ld",
|
||||
__program_name,file,line,mn->mn_Allocation,size);
|
||||
__program_name, file, line, mn->mn_Allocation, mn->mn_OriginalSize);
|
||||
|
||||
if(mn->mn_File != NULL)
|
||||
kprintf(", allocated at %s:%ld",mn->mn_File,mn->mn_Line);
|
||||
if (mn->mn_File != NULL)
|
||||
kprintf(", allocated at %s:%ld", mn->mn_File, mn->mn_Line);
|
||||
|
||||
kprintf(", has already been freed at %s:%ld.\n",mn->mn_FreeFile,mn->mn_FreeLine);
|
||||
kprintf(", has already been freed at %s:%ld.\n", mn->mn_FreeFile, mn->mn_FreeLine);
|
||||
}
|
||||
}
|
||||
#else
|
||||
@@ -518,7 +504,7 @@ __free_memory_node(struct MemoryNode * mn,const char * UNUSED file,int UNUSED li
|
||||
/****************************************************************************/
|
||||
|
||||
VOID
|
||||
__free_memory(void * ptr,BOOL force,const char * file,int line)
|
||||
__free_memory(void * ptr, BOOL force, const char * file, int line)
|
||||
{
|
||||
struct MemoryNode * mn;
|
||||
|
||||
@@ -529,7 +515,7 @@ __free_memory(void * ptr,BOOL force,const char * file,int line)
|
||||
|
||||
#ifdef __MEM_DEBUG
|
||||
{
|
||||
/*if((rand() % 16) == 0)
|
||||
/*if ((rand() % 16) == 0)
|
||||
__check_memory_allocations(file,line);*/
|
||||
}
|
||||
#endif /* __MEM_DEBUG */
|
||||
@@ -538,34 +524,37 @@ __free_memory(void * ptr,BOOL force,const char * file,int line)
|
||||
|
||||
#ifdef __MEM_DEBUG
|
||||
{
|
||||
if(mn != NULL)
|
||||
if (mn != NULL)
|
||||
{
|
||||
if(force || FLAG_IS_CLEAR(mn->mn_Size, MN_SIZE_NEVERFREE))
|
||||
__free_memory_node(mn,file,line);
|
||||
if (force || FLAG_IS_CLEAR(mn->mn_Flags, MNF_NEVER_FREE))
|
||||
__free_memory_node(mn, file, line);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef __MEM_DEBUG_LOG
|
||||
{
|
||||
kprintf("[%s] - %10ld 0x%08lx [",__program_name,0,ptr);
|
||||
kprintf("[%s] - %10ld 0x%08lx [", __program_name, 0, ptr);
|
||||
|
||||
kprintf("FAILED]\n");
|
||||
}
|
||||
#endif /* __MEM_DEBUG_LOG */
|
||||
|
||||
kprintf("[%s] %s:%ld:Address for free(0x%08lx) not known.\n",__program_name,file,line,ptr);
|
||||
kprintf("[%s] %s:%ld:Address for free(0x%08lx) not known.\n", __program_name, file, line, ptr);
|
||||
|
||||
D(("memory allocation at 0x%08lx could not be freed",ptr));
|
||||
D(("memory allocation at 0x%08lx could not be freed", ptr));
|
||||
}
|
||||
}
|
||||
#else
|
||||
{
|
||||
assert( mn != NULL );
|
||||
|
||||
SHOWVALUE(mn->mn_Size);
|
||||
if (FLAG_IS_SET(mn->mn_Flags, MNF_NEVER_FREE))
|
||||
D(("mn->mn_AllocationSize=%ld (0x%08lx), not to be freed", mn->mn_AllocationSize, mn->mn_AllocationSize));
|
||||
else
|
||||
D(("mn->mn_AllocationSize=%ld (0x%08lx)", mn->mn_AllocationSize, mn->mn_AllocationSize));
|
||||
|
||||
if(mn != NULL && (force || FLAG_IS_CLEAR(mn->mn_Size, MN_SIZE_NEVERFREE)))
|
||||
__free_memory_node(mn,file,line);
|
||||
if (mn != NULL && (force || FLAG_IS_CLEAR(mn->mn_Flags, MNF_NEVER_FREE)))
|
||||
__free_memory_node(mn, file, line);
|
||||
}
|
||||
#endif /* __MEM_DEBUG */
|
||||
}
|
||||
@@ -578,13 +567,13 @@ __free(void * ptr,const char * file,int line)
|
||||
__memory_lock();
|
||||
|
||||
/* Try to get rid of now unused memory. */
|
||||
if(__alloca_cleanup != NULL)
|
||||
(*__alloca_cleanup)(file,line);
|
||||
if (__alloca_cleanup != NULL)
|
||||
(*__alloca_cleanup)(file, line);
|
||||
|
||||
__memory_unlock();
|
||||
|
||||
if(ptr != NULL)
|
||||
__free_memory(ptr,FALSE,file,line);
|
||||
if (ptr != NULL)
|
||||
__free_memory(ptr, FALSE, file, line);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
@@ -592,5 +581,5 @@ __free(void * ptr,const char * file,int line)
|
||||
void
|
||||
free(void * ptr)
|
||||
{
|
||||
__free(ptr,NULL,0);
|
||||
__free(ptr, NULL, 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user