Skip to content

Instantly share code, notes, and snippets.

@dimenus
Created May 23, 2017 15:16
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 dimenus/866cec1b75bfdc0c5394493cbc66909a to your computer and use it in GitHub Desktop.
Save dimenus/866cec1b75bfdc0c5394493cbc66909a to your computer and use it in GitHub Desktop.
dynamic array
struct IntArray
{
int Length;
int MaxLength;
int *Data;
};
void PushToIntArray(struct IntArray *int_array, int value)
{
if((int_array->Length + 1) >= int_array->MaxLength) {
//log errors or reallocate
return;
}
int_array->Data[int_array->Length] = value;
int_array->Length += 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment