diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-05-24 10:40:07 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-05-24 10:40:07 -0600 |
commit | f3f00384b43f110c230725f0d75317fe1b0fcb85 (patch) | |
tree | 6aed4e32577a1b9b05bb56060d9751d91cd37668 /apps/examples/mm | |
parent | 97a8f813e234bc11b36c40b7bc9c674679bce262 (diff) | |
download | px4-nuttx-f3f00384b43f110c230725f0d75317fe1b0fcb85.tar.gz px4-nuttx-f3f00384b43f110c230725f0d75317fe1b0fcb85.tar.bz2 px4-nuttx-f3f00384b43f110c230725f0d75317fe1b0fcb85.zip |
Costmetic changes to memory manager debug output
Diffstat (limited to 'apps/examples/mm')
-rw-r--r-- | apps/examples/mm/mm_main.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/apps/examples/mm/mm_main.c b/apps/examples/mm/mm_main.c index c15004a34..bf7e1f06d 100644 --- a/apps/examples/mm/mm_main.c +++ b/apps/examples/mm/mm_main.c @@ -149,11 +149,14 @@ static void do_mallocs(void **mem, const int *size, const int *seq, int n) if (!mem[j]) { printf("(%d)Allocating %d bytes\n", i, size[j]); + mem[j] = malloc(size[j]); printf("(%d)Memory allocated at %p\n", i, mem[j]); + if (mem[j] == NULL) { int allocsize = MM_ALIGN_UP(size[j] + SIZEOF_MM_ALLOCNODE); + fprintf(stderr, "(%d)malloc failed for allocsize=%d\n", i, allocsize); if (allocsize > alloc_info.mxordblk) { @@ -167,7 +170,7 @@ static void do_mallocs(void **mem, const int *size, const int *seq, int n) } else { - memset(mem[j], 0xAA, size[j]); + memset(mem[j], 0xaa, size[j]); } mm_showmallinfo(); @@ -185,11 +188,14 @@ static void do_reallocs(void **mem, const int *oldsize, const int *newsize, cons j = seq[i]; printf("(%d)Re-allocating at %p from %d to %d bytes\n", i, mem[j], oldsize[j], newsize[j]); + mem[j] = realloc(mem[j], newsize[j]); printf("(%d)Memory re-allocated at %p\n", i, mem[j]); + if (mem[j] == NULL) { int allocsize = MM_ALIGN_UP(newsize[j] + SIZEOF_MM_ALLOCNODE); + fprintf(stderr, "(%d)realloc failed for allocsize=%d\n", i, allocsize); 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]; printf("(%d)Allocating %d bytes aligned to 0x%08x\n", i, size[j], align[i]); + mem[j] = memalign(align[i], size[j]); printf("(%d)Memory allocated at %p\n", i, mem[j]); + if (mem[j] == NULL) { int allocsize = MM_ALIGN_UP(size[j] + SIZEOF_MM_ALLOCNODE) + 2*align[i]; + fprintf(stderr, "(%d)memalign failed for allocsize=%d\n", i, allocsize); 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++) { j = seq[i]; + printf("(%d)Releasing memory at %p (size=%d bytes)\n", i, mem[j], size[j]); + free(mem[j]); mem[j] = NULL; |