Lines Matching refs:array
36 void arrayFree(Array* array) { in arrayFree() argument
37 assert(array != NULL); in arrayFree()
40 free(array->contents); in arrayFree()
43 free(array); in arrayFree()
47 static int ensureCapacity(Array* array, int capacity) { in ensureCapacity() argument
48 int oldCapacity = array->capacity; in ensureCapacity()
71 if (array->contents == NULL) { in ensureCapacity()
79 newContents = realloc(array->contents, sizeof(void*) * newCapacity); in ensureCapacity()
85 array->capacity = newCapacity; in ensureCapacity()
86 array->contents = newContents; in ensureCapacity()
92 int arrayAdd(Array* array, void* pointer) { in arrayAdd() argument
93 assert(array != NULL); in arrayAdd()
94 int size = array->size; in arrayAdd()
95 int result = ensureCapacity(array, size + 1); in arrayAdd()
99 array->contents[size] = pointer; in arrayAdd()
100 array->size++; in arrayAdd()
104 static inline void checkBounds(Array* array, int index) { in checkBounds() argument
105 assert(array != NULL); in checkBounds()
106 assert(index < array->size); in checkBounds()
110 void* arrayGet(Array* array, int index) { in arrayGet() argument
111 checkBounds(array, index); in arrayGet()
112 return array->contents[index]; in arrayGet()
115 void* arrayRemove(Array* array, int index) { in arrayRemove() argument
116 checkBounds(array, index); in arrayRemove()
118 void* pointer = array->contents[index]; in arrayRemove()
120 int newSize = array->size - 1; in arrayRemove()
124 memmove(array->contents + index, array->contents + index + 1, in arrayRemove()
128 array->size = newSize; in arrayRemove()
133 void* arraySet(Array* array, int index, void* pointer) { in arraySet() argument
134 checkBounds(array, index); in arraySet()
135 void* old = array->contents[index]; in arraySet()
136 array->contents[index] = pointer; in arraySet()
140 int arraySetSize(Array* array, int newSize) { in arraySetSize() argument
141 assert(array != NULL); in arraySetSize()
144 int oldSize = array->size; in arraySetSize()
148 int result = ensureCapacity(array, newSize); in arraySetSize()
154 memset(array->contents + sizeof(void*) * oldSize, 0, in arraySetSize()
158 array->size = newSize; in arraySetSize()
163 int arraySize(Array* array) { in arraySize() argument
164 assert(array != NULL); in arraySize()
165 return array->size; in arraySize()
168 const void** arrayUnwrap(Array* array) { in arrayUnwrap() argument
169 return (const void**)array->contents; in arrayUnwrap()