Skip to content

Instantly share code, notes, and snippets.

@DenisBelmondo
Last active January 31, 2024 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DenisBelmondo/a1db7054fd94c044a631359b8a8110a0 to your computer and use it in GitHub Desktop.
Save DenisBelmondo/a1db7054fd94c044a631359b8a8110a0 to your computer and use it in GitHub Desktop.
c89 type safe dynamic array (test bed)
#include <stdio.h>
#include "array.h"
typedef Array(int) IntArray;
int main(void) {
IntArray a;
size_t i;
array_init(&a);
array_push_back(&a, 128);
array_push_back(&a, 256);
array_push_back(&a, 1);
array_push_back(&a, 2);
array_push_back(&a, 3);
array_push_back(&a, 1);
array_push_back(&a, 2);
array_push_back(&a, 3);
array_push_front(&a, 512);
for (i = 0; i < a.count; i++) {
printf("%d\n", a.data[i]);
}
printf("%zu\n", a.capacity);
array_deinit(&a);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment