开发者

What is the best way to manage a queue of structs in C?

开发者 https://www.devze.com 2023-03-23 11:43 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号