views:

95

answers:

3

I'm working on a existing embedded system (memory is limited, Flash is limited, ...) with an RT OS. All data structures have a fixed size and are allocated at "compile time" and are therefore suited for RT. There is no dynamic memory allocation. The programming language is C++, but there is no STL available. I like to replace some of the data structures especially LinkedList, Vector and Map with some more generic variants.

The closest I've seen so far is the following framework: http://apfw.sourceforge.net/. The biggest draw back IMHO is that the for a LinkedList with size N, the default constructor from T is called N times. A better class should statically allocate sizeof(T)*N bytes.

Does anyone know I library with all of the above constraints?

+1  A: 

If you are fixing the size of the LinkedList, why not just create your own simple class and back it by an array?

Anon
Because there are maybe 10% of the methods needed, compared what the STL provides, that would be feasible. I guess if no one already knows a library I'll write my own class, post it here, and let the experts decide, what I f..... up.
azraiyl
+1  A: 

Have you considered passing your own allocator (allocating from a static pool) to STL containers?

Other than that, I don't think anything like this exists. You might want to look at this related question to get started with a static vector class. If you do this, consider to make it Open Source.

sbi
Currently the target has no STL. If there was enough Flash available (the download link is a serial line with ca. 2 KiBytes/s, therefore even if I add more Flash I've a problem) I guess the STL with an O(1) memory allocator (e.g. http://rtportal.upv.es/rtmalloc/) would be ok. I've to admit that I never tried to chop up the STL in small pieces.
azraiyl
+1  A: 

May I recommend you the following:

http://www.codeproject.com/KB/recipes/Containers.aspx

It's an article I've written about anoter design of container classes. One of the biggest advantages of them is that allocating the data and storing it in the container are separated.

You may for instance declare your static data at compile-time, and then in run-time insert/remove it to/from the list/tree/etc.

valdo