Syntax
#include <malloc.h>
int malloc_memdsp(unsigned char *s, int size)
int mt_malloc_memdsp(unsigned char *s, int size)
Arguments
s pointer to the character string
size size of the character string divided by 60
Return Value
The size used divided by 60
Description
Makes 60 digits into 1 line for the specified one-dimensional character string, and returns information on the memory allocation area as character information. Note that the character string must be a multiple of 60x2.
mt_malloc_memdsp is the multi-thread compatible version of malloc_memdsp. Interruption is inhibited when processing is being performed to prevent malfunction if used by more than one thread.
Example: Displaying character information
#define MEMCHECK_STRINGLEN 10
void dsp_memcheck(void)
{
int i, j;
char s[MEMCHECK_STRINGLEN*60];
i = malloc_memdsp(s, MEMCHECK_STRINGLEN);
for (j=0; j<i;j++)
osSyncPrintf("%s\n",s+j*60);
}
Character information is displayed in two lines:
Line One
"########:$$$$$$$$-&&&&&&&&" ######## - the address to store head information $$$$$$$$ - the head address of ensured or freed memory block &&&&&&&& - the end address of ensured or freed memory block
Line Two - displays the head information of the memory block
" (########)[$$$$$$$$] FREE" " (########)[$$$$$$$$] USE" " (########)[$$$$$$$$] ALIN" ######## - the size of memory block in bytes $$$$$$$$ - the address of the following head information FREE - Memory block is free and in the range of usage USE - Memory block is in use ALIN - Memory block only with 0 as size of head to compensate alignment when using memalign function
If the content is invalid
"malloc_memdsp error:######## over area $$$$$$$$-&&&&&&&&" Address to the next header information is over the range that is ensured with InitHeap() function. "malloc_memdsp error:check InitHeap()" malloc_memdsp() function is called without InitHeap() function being executed or the head information in the first memory block is invalid.
Revision History
6/1/99 Added explanation of the multi-thread version