We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
When:
init_mempool(0x0000, 1024); p = malloc(10);
init_mempool(0x2000, 1024); p = malloc(10);
"Perhaps you should just take a step back and ask youself why you want to use dynamic memory allocation on a small embedded controller like the 8051? " I'm designing GUI components which will be displayed on a LCD panel. Each component is a small rectangular window on the display. To paint the component, I first get a canvas from the component, then draw shapes and strings on it, finally paint the canvas onto the display. The canvas is essentially a block of memory, whose size is different from component to component. Yes I can pre-define a global (or static) canvas which is big enough to hold any individual components. And there is nearly no more benefit to use the dynamic memory allocation than the fixed memory allocation in terms of the usage of memory. But the former seems more elegant, I think. Anyway, I appreciate your advice, and perhaps I will take your advice some day.