13

I wonder if there is an alternative for the std::vector in C? I found this implementation but it seems to contain some issues with memory reallocation.

ezpresso
  • 7,438
  • 12
  • 59
  • 91

3 Answers3

10

You can give glib and its arrays (GArray) a try.

glib is actively maintained, cross platform, open source (LGPLv2+), and it doesn't stop on arrays/vectors. You also have hash tables, linked lists, queues and many other data structures.

Cristian Ciupitu
  • 19,240
  • 7
  • 48
  • 73
Pablo Santa Cruz
  • 170,119
  • 31
  • 233
  • 283
9

While reading C Array vs. C++ Vector, I found an interesting implementation of a simple vector container in C, which also includes push/pop operations. It's worth reading it!

The Guy
  • 106
  • 2
-1

If you focus is on mathematics you can work with GSL, there have a more bare bones math centric concept.

cmaynard
  • 2,761
  • 2
  • 22
  • 32