Costmetic changes to memory manager debug output
This commit is contained in:
parent
17d4498c0a
commit
35b94281af
@ -149,11 +149,14 @@ static void do_mallocs(void **mem, const int *size, const int *seq, int n)
|
|||||||
if (!mem[j])
|
if (!mem[j])
|
||||||
{
|
{
|
||||||
printf("(%d)Allocating %d bytes\n", i, size[j]);
|
printf("(%d)Allocating %d bytes\n", i, size[j]);
|
||||||
|
|
||||||
mem[j] = malloc(size[j]);
|
mem[j] = malloc(size[j]);
|
||||||
printf("(%d)Memory allocated at %p\n", i, mem[j]);
|
printf("(%d)Memory allocated at %p\n", i, mem[j]);
|
||||||
|
|
||||||
if (mem[j] == NULL)
|
if (mem[j] == NULL)
|
||||||
{
|
{
|
||||||
int allocsize = MM_ALIGN_UP(size[j] + SIZEOF_MM_ALLOCNODE);
|
int allocsize = MM_ALIGN_UP(size[j] + SIZEOF_MM_ALLOCNODE);
|
||||||
|
|
||||||
fprintf(stderr, "(%d)malloc failed for allocsize=%d\n", i, allocsize);
|
fprintf(stderr, "(%d)malloc failed for allocsize=%d\n", i, allocsize);
|
||||||
if (allocsize > alloc_info.mxordblk)
|
if (allocsize > alloc_info.mxordblk)
|
||||||
{
|
{
|
||||||
@ -167,7 +170,7 @@ static void do_mallocs(void **mem, const int *size, const int *seq, int n)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memset(mem[j], 0xAA, size[j]);
|
memset(mem[j], 0xaa, size[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
mm_showmallinfo();
|
mm_showmallinfo();
|
||||||
@ -185,11 +188,14 @@ static void do_reallocs(void **mem, const int *oldsize, const int *newsize, cons
|
|||||||
j = seq[i];
|
j = seq[i];
|
||||||
printf("(%d)Re-allocating at %p from %d to %d bytes\n",
|
printf("(%d)Re-allocating at %p from %d to %d bytes\n",
|
||||||
i, mem[j], oldsize[j], newsize[j]);
|
i, mem[j], oldsize[j], newsize[j]);
|
||||||
|
|
||||||
mem[j] = realloc(mem[j], newsize[j]);
|
mem[j] = realloc(mem[j], newsize[j]);
|
||||||
printf("(%d)Memory re-allocated at %p\n", i, mem[j]);
|
printf("(%d)Memory re-allocated at %p\n", i, mem[j]);
|
||||||
|
|
||||||
if (mem[j] == NULL)
|
if (mem[j] == NULL)
|
||||||
{
|
{
|
||||||
int allocsize = MM_ALIGN_UP(newsize[j] + SIZEOF_MM_ALLOCNODE);
|
int allocsize = MM_ALIGN_UP(newsize[j] + SIZEOF_MM_ALLOCNODE);
|
||||||
|
|
||||||
fprintf(stderr, "(%d)realloc failed for allocsize=%d\n", i, allocsize);
|
fprintf(stderr, "(%d)realloc failed for allocsize=%d\n", i, allocsize);
|
||||||
if (allocsize > alloc_info.mxordblk)
|
if (allocsize > alloc_info.mxordblk)
|
||||||
{
|
{
|
||||||
@ -220,11 +226,14 @@ static void do_memaligns(void **mem, const int *size, const int *align, const in
|
|||||||
j = seq[i];
|
j = seq[i];
|
||||||
printf("(%d)Allocating %d bytes aligned to 0x%08x\n",
|
printf("(%d)Allocating %d bytes aligned to 0x%08x\n",
|
||||||
i, size[j], align[i]);
|
i, size[j], align[i]);
|
||||||
|
|
||||||
mem[j] = memalign(align[i], size[j]);
|
mem[j] = memalign(align[i], size[j]);
|
||||||
printf("(%d)Memory allocated at %p\n", i, mem[j]);
|
printf("(%d)Memory allocated at %p\n", i, mem[j]);
|
||||||
|
|
||||||
if (mem[j] == NULL)
|
if (mem[j] == NULL)
|
||||||
{
|
{
|
||||||
int allocsize = MM_ALIGN_UP(size[j] + SIZEOF_MM_ALLOCNODE) + 2*align[i];
|
int allocsize = MM_ALIGN_UP(size[j] + SIZEOF_MM_ALLOCNODE) + 2*align[i];
|
||||||
|
|
||||||
fprintf(stderr, "(%d)memalign failed for allocsize=%d\n", i, allocsize);
|
fprintf(stderr, "(%d)memalign failed for allocsize=%d\n", i, allocsize);
|
||||||
if (allocsize > alloc_info.mxordblk)
|
if (allocsize > alloc_info.mxordblk)
|
||||||
{
|
{
|
||||||
@ -253,8 +262,10 @@ static void do_frees(void **mem, const int *size, const int *seq, int n)
|
|||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
j = seq[i];
|
j = seq[i];
|
||||||
|
|
||||||
printf("(%d)Releasing memory at %p (size=%d bytes)\n",
|
printf("(%d)Releasing memory at %p (size=%d bytes)\n",
|
||||||
i, mem[j], size[j]);
|
i, mem[j], size[j]);
|
||||||
|
|
||||||
free(mem[j]);
|
free(mem[j]);
|
||||||
mem[j] = NULL;
|
mem[j] = NULL;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user