This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

When I setup memory pool beginning with 0x0000, malloc doesn't work.

When:

init_mempool(0x0000, 1024);
p = malloc(10);
malloc always returns NULL.
But when:
init_mempool(0x2000, 1024);
p = malloc(10);
p gets a valid address.
Why does this happen?
Thanks.

Parents Reply Children

  • "What else in your program might use memory starting at address 0? Have you reserved that range of memory to use as your heap? I'd expect the heap to start near the top of memory (under any reentrant stack), unless you have no other xdata usage whatsoever. "

    Yes, this is the matter.
    An array should be declared to reserve the memory used by the heap.
    I'm thinking why init_mempool doesn't do that for me?
    Thanks a lot.

    d.curie