What is the best way to manage a queue of structs in C?
I've got a series of structs (audio data) which I need to hold onto but I can only hold onto a limited amount due to memory constraints. I think the best way to do this is with a queue. If I were do this based on my fuzzy memories of my college classes I would create a linked list with pointers. I would push new items onto the queue and pop old items off and free tha开发者_开发百科t memory.
Is there a C library that I use should to manage this queue so that I do not have to reinvent the wheel?
GLib has a good and well-documented collection of data structures implemented in C, give a look at it.
If you can use C++, you have std::list in the standard library.
It sounds like what you're describing is a cache
, not a queue
.
精彩评论