From c601d953ae2de87bc41d3666f6b510805bf4e67b Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 14 Mar 2013 18:30:06 +0000 Subject: itoa() from Ryan Sundberg git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5741 42af7a65-404d-4744-a932-0658087f49c3 --- apps/examples/README.txt | 6 +----- apps/examples/mm/mm_main.c | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 17 deletions(-) (limited to 'apps/examples') diff --git a/apps/examples/README.txt b/apps/examples/README.txt index 03d43f1a0..ff22580d0 100644 --- a/apps/examples/README.txt +++ b/apps/examples/README.txt @@ -627,11 +627,7 @@ examples/lcdrw examples/mm ^^^^^^^^^^^ - This is a simplified version of the "built-in" memory manager test of - mm/mm_test.c. It is simplified because it does not have access to the - internals of the memory manager as does mm/mm_test.c, but it has the - advantage that it runs in the actual NuttX tasking environment (the - mm/mm_test.c only runs in a PC simulation environment). + This is a simple test of the memory manager. examples/modbus ^^^^^^^^^^^^^^^ diff --git a/apps/examples/mm/mm_main.c b/apps/examples/mm/mm_main.c index 149550418..0c8532d70 100644 --- a/apps/examples/mm/mm_main.c +++ b/apps/examples/mm/mm_main.c @@ -127,15 +127,15 @@ static void mm_showmallinfo(void) alloc_info = mallinfo(); printf(" mallinfo:\n"); printf(" Total space allocated from system = %ld\n", - alloc_info.arena); + alloc_info.arena); printf(" Number of non-inuse chunks = %ld\n", - alloc_info.ordblks); + alloc_info.ordblks); printf(" Largest non-inuse chunk = %ld\n", - alloc_info.mxordblk); + alloc_info.mxordblk); printf(" Total allocated space = %ld\n", - alloc_info.uordblks); + alloc_info.uordblks); printf(" Total non-inuse space = %ld\n", - alloc_info.fordblks); + alloc_info.fordblks); } static void do_mallocs(void **mem, const int *size, const int *seq, int n) @@ -184,11 +184,11 @@ 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]); + 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) @@ -200,7 +200,7 @@ static void do_reallocs(void **mem, const int *oldsize, const int *newsize, cons fprintf(stderr, " ERROR largest free block is %ld\n", alloc_info.mxordblk); exit(1); } - } + } else { memset(mem[j], 0x55, newsize[j]); @@ -219,11 +219,11 @@ 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]); + 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) @@ -235,7 +235,7 @@ static void do_memaligns(void **mem, const int *size, const int *align, const in fprintf(stderr, " ERROR largest free block is %ld\n", alloc_info.mxordblk); exit(1); } - } + } else { memset(mem[j], 0x33, size[j]); @@ -254,7 +254,7 @@ static void do_frees(void **mem, const int *size, const int *seq, int n) { j = seq[i]; printf("(%d)Releasing memory at %p (size=%d bytes)\n", - i, mem[j], size[j]); + i, mem[j], size[j]); free(mem[j]); mem[j] = NULL; -- cgit v1.2.3