Cannot aloocate memory using malloc

Hi All,
I have implemented a linked list in my program on infineon sle66c168PE.

at very first time i intialize the starting node with the null value and whenever i need to add the node to the linked list the malloc function return me the value 0x0000 that is a null value.which causes the program to fail.

can anyone please suggest me something to work-around this problem...
its very urgent ...Plz
Thanks and Regards,
Ankit

Parents
  • ankit,

    If you're just doing this as a learning exercise, that's fine, but you really should reconsider using malloc within an 8051 project that's to be sold to an end user. Malloc is useful in a PC or general purpose computing environment when you don't know how much RAM the system might contain. In the case of embedded systems, however, you typically know the total amount of RAM as well as how much of that RAM you can afford to devote to storing your data. What I'm saying is: Just make a static variable of a size appropriate to hold the maximum dataset you'll need to work with.

    Abandon malloc before you're in too deep.

Reply
  • ankit,

    If you're just doing this as a learning exercise, that's fine, but you really should reconsider using malloc within an 8051 project that's to be sold to an end user. Malloc is useful in a PC or general purpose computing environment when you don't know how much RAM the system might contain. In the case of embedded systems, however, you typically know the total amount of RAM as well as how much of that RAM you can afford to devote to storing your data. What I'm saying is: Just make a static variable of a size appropriate to hold the maximum dataset you'll need to work with.

    Abandon malloc before you're in too deep.

Children
More questions in this forum