Thread: Malloc, etc...
View Single Post
  #5   Spotlight this post!  
Unread 05-01-2004, 01:28
JimWright949's Avatar
JimWright949 JimWright949 is offline
The Owen Day of Seattle
AKA: Jim Wright
FRC #4542 (Titanium Talons)
Team Role: Mentor
 
Join Date: Sep 2003
Rookie Year: 2003
Location: Redmond, WA
Posts: 94
JimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to behold
Re: Malloc, etc...

Ryan,

As a firmware developer by trade, we don't tend to use malloc in real embedded applications. The trouble is that there just isn't room for linked lists and other non-static memory uses.

If you need a list I would suggest a global queue or stack of a static size (10 to 20 items [or even an array]). This is to ensure other parts of your application get the memory they need. Now to get into the data hiding aspect that you probably want, make a few accessor functions to this global item (GetValue and PutValue) that handle talking to the global structure.

The reason for this is that the stack needs to be protected and if a link list goes wrong it could corrupt all sorts of memory. Another reason is that embedded applications just don't have the memory management code in them to handle malloc and free.

-Jim Wright