itoa() from Ryan Sundberg
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5741 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
0b6519156e
commit
80ffd26450
@ -627,11 +627,7 @@ examples/lcdrw
|
|||||||
examples/mm
|
examples/mm
|
||||||
^^^^^^^^^^^
|
^^^^^^^^^^^
|
||||||
|
|
||||||
This is a simplified version of the "built-in" memory manager test of
|
This is a simple test of the memory manager.
|
||||||
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).
|
|
||||||
|
|
||||||
examples/modbus
|
examples/modbus
|
||||||
^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^
|
||||||
|
@ -127,15 +127,15 @@ static void mm_showmallinfo(void)
|
|||||||
alloc_info = mallinfo();
|
alloc_info = mallinfo();
|
||||||
printf(" mallinfo:\n");
|
printf(" mallinfo:\n");
|
||||||
printf(" Total space allocated from system = %ld\n",
|
printf(" Total space allocated from system = %ld\n",
|
||||||
alloc_info.arena);
|
alloc_info.arena);
|
||||||
printf(" Number of non-inuse chunks = %ld\n",
|
printf(" Number of non-inuse chunks = %ld\n",
|
||||||
alloc_info.ordblks);
|
alloc_info.ordblks);
|
||||||
printf(" Largest non-inuse chunk = %ld\n",
|
printf(" Largest non-inuse chunk = %ld\n",
|
||||||
alloc_info.mxordblk);
|
alloc_info.mxordblk);
|
||||||
printf(" Total allocated space = %ld\n",
|
printf(" Total allocated space = %ld\n",
|
||||||
alloc_info.uordblks);
|
alloc_info.uordblks);
|
||||||
printf(" Total non-inuse space = %ld\n",
|
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)
|
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];
|
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)
|
||||||
@ -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);
|
fprintf(stderr, " ERROR largest free block is %ld\n", alloc_info.mxordblk);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memset(mem[j], 0x55, newsize[j]);
|
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];
|
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)
|
||||||
@ -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);
|
fprintf(stderr, " ERROR largest free block is %ld\n", alloc_info.mxordblk);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memset(mem[j], 0x33, size[j]);
|
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];
|
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