Home > Back-end >  51 init_mempool inside () and free (), malloc () function is used
51 init_mempool inside () and free (), malloc () function is used

Time:10-03

I use 51. Write a dynamic memory program to use malloc () to set up dynamic memory, with free () to release the memory, before the release of 1602 liquid crystal display malloc () set up the dynamic value of each element of an array of found that if you don't give init_mempool () function to initialize the LCD can't display normal character excuse me how can I give init_mempool () function to initialize the trouble you give me see
No initialization for the warning, and cannot display
* * * WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ? PR? _INIT_MEMPOOL? INIT_MEM

CodePudding user response:

Malloc usually just opened up the memory, that is, you can use these addresses, but these addresses the value might be junk, you can try memset, all initialized to 0 see...

CodePudding user response:

In PC malloc () do not need to initialize memory pool before, because the operating system runs all memory


For the C51 is different, because there is no operating system, the need for dynamic memory allocation range is not clear, need a header file & lt; stdlib.h> Need to invoke init_mempool initial memory pool,

Void init_mempool (void _MALLOC_MEM_ * p, unsigned int size);//start address and size

Use malloc () or realloc () dynamically allocated memory may contain garbage data, use calloc () get the memory for all zero,

CodePudding user response:

Memory is initialized to zero

CodePudding user response:

refer to the second floor songhtao response:
in PC malloc () before you do not need to initialize memory pool, because the operating system runs all memory


For the C51 is different, because there is no operating system, the need for dynamic memory allocation range is not clear, need a header file & lt; stdlib.h> Need to invoke init_mempool initial memory pool,

Void init_mempool (void _MALLOC_MEM_ * p, unsigned int size);//start address and size

Use malloc () or realloc () dynamically allocated memory may contain garbage data, use calloc () get the memory for all zero,
C51 inside of concrete is how to allocate memory columns such as define a global variable these variables are assigned to a static variable that define a dynamic array is allocated memory area where is external ram or internal ram you specifically understand C51 inside the address of the memory to store data and a brief explanation of the whole memory area do or you can advise me some references and then to read the
  • Related