Handmade Hero»Forums»Code
195 posts
Any good C data structure libraries?
Edited by Jason on Reason: Initial post
I'm trying to implement my own dynamic memory allocator and in the process of doing so I would like to utilize a linked list structure. Since I don't feel like trying to implement one myself at the moment I tried using STL's linked list just as a current solution. I've had numerous issues trying to get it working so I was wondering if anyone has used and can vouch for any C style libraries for things liked linked lists, arrays, etc?
Mārtiņš Možeiko
2198 posts / 1 project
Any good C data structure libraries?
If you need just linked list, I would suggest to implement it yourself. Depending on functionality you need it can be very small amount of code - 10/20 lines or so.

As for ready-to-use C code for data structures:
  • here's OpenBSD queue.h and tree.h that implements various queues (singly/doubly linked lists/arrays) and tree structures
  • klib good implementation for various data structures
  • TommyDS with various stuff
  • libldfs if you need lock-free data structures
  • stb.h - also has some data structures

You can also take a look at some implementations of memory allocators to see what they use:
  • tlsf - implements linked list within its data structure, not as external wrapper
  • Hoard
  • nedmalloc
  • ltalloc - C++ not C, but does not use STL

63 posts
Professional programmer, working in the video games industry since 2012
Any good C data structure libraries?

Compared with implementing a whole dynamic memory allocator, implementing a linked list structure will be a breeze, a simple one can be implemented in a few minutes, or maybe a few hours if you're an absolute beginner. Additionally, it is one more opportunity to practice programming to train yourself.
195 posts
Any good C data structure libraries?
Thanks mmozeiko! And ya I'm sure its not too hard to implement one. I just wanted a quick way to grab something that works reasonably well already while I try and focus on my initial problem. Though I might end up implementing one still we'll see. Thanks again!