if (C->Count >= C->Size) {
/* Must grow */
void** NewItems;
- C->Size *= 2;
+ if (C->Size > 0) {
+ C->Size *= 2;
+ } else {
+ C->Size = 8;
+ }
NewItems = xmalloc (C->Size * sizeof (void*));
memcpy (NewItems, C->Items, C->Count * sizeof (void*));
xfree (C->Items);
void** Items; /* Array with dynamic size */
};
+/* Initializer for static collections */
+#define STATIC_COLLECTION_INITIALIZER { 0, 0, 0 }
+
/*****************************************************************************/
*/
Collection* NewCollection (void);
-/* Create and return a new collection with the given initial size */
+/* Create and return a new collection */
void FreeCollection (Collection* C);
/* Free a collection */