[Etherboot-developers] Allocating memory...
Brought to you by:
marty_connor,
stefanhajnoczi
|
From: Eric W B. <ebi...@ln...> - 2002-07-31 19:42:02
|
If for nothing else except the multicast there is a need to allocate memory in etherboot. Implementing malloc and free is completely overkill for the problem. GNU obstacks are close to what I want but have the potential to be confused normall malloc and free. So I have dug out my FORTH references and have found another set of names. void *allot(size_t size); void forget(void *ptr); allot allocates memory of a given size with a worst case alignment just like malloc, but memory is freed differently. forget frees the indicated object and all other ojbects allocated after the indicated object. allot and forget work with a stack instead of the more common random access heap. Using a stack allows a much simpler allocation and freeing code (push,pop). Management is much simpler because you can generally allot and not explictly forget the memory. Just so long as you aren't restarted without forgetting there isn't a memory leak. Eric |