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,896
  • 13
  • 62
  • 94

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
  • 20,270
  • 7
  • 50
  • 76
Pablo Santa Cruz
  • 176,835
  • 32
  • 241
  • 292
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,852
  • 2
  • 24
  • 34