static void dyn_array_empty (DynArray *da) { if (da->capacity < 0) dyn_array_init (da); else da->size = 0; }
static void dyn_array_uninit (DynArray *da, int elem_size) { if (da->capacity < 0) { dyn_array_init (da); return; } if (da->capacity == 0) return; sgen_free_internal_dynamic (da->data, elem_size * da->capacity, INTERNAL_MEM_BRIDGE_DATA); da->data = NULL; }
static void* dyn_array_ptr_pop (DynPtrArray *da) { int size = da->array.size; void *p; g_assert (size > 0); if (da->array.capacity == 1) { p = dyn_array_ptr_get (da, 0); dyn_array_init (&da->array); } else { g_assert (da->array.capacity > 1); dyn_array_ensure_independent (&da->array, sizeof (void*)); p = dyn_array_ptr_get (da, size - 1); --da->array.size; } return p; }
static void* dyn_array_ptr_pop (DynPtrArray *da) { int size = da->array.size; void *p; g_assert (size > 0); #ifdef OPTIMIZATION_SINGLETON_DYN_ARRAY if (da->array.capacity == 1) { p = dyn_array_ptr_get (da, 0); dyn_array_init (&da->array); } else #endif { g_assert (da->array.capacity > 1); dyn_array_ensure_independent (&da->array, sizeof (void*)); p = dyn_array_ptr_get (da, size - 1); --da->array.size; } return p; }
static void dyn_array_ptr_add (DynPtrArray *da, void *ptr) { void **p; if (da->array.capacity == 0) { da->array.capacity = 1; da->array.size = 1; p = (void**)&da->array.data; } else if (da->array.capacity == 1) { void *ptr0 = da->array.data; void **p0; dyn_array_init (&da->array); p0 = dyn_array_add (&da->array, sizeof (void*)); *p0 = ptr0; p = dyn_array_add (&da->array, sizeof (void*)); } else { p = dyn_array_add (&da->array, sizeof (void*)); } *p = ptr; }
static void dyn_array_ptr_add (DynPtrArray *da, void *ptr) { void **p; #ifdef OPTIMIZATION_SINGLETON_DYN_ARRAY if (da->array.capacity == 0) { da->array.capacity = 1; da->array.size = 1; p = (void**)&da->array.data; } else if (da->array.capacity == 1) { void *ptr0 = da->array.data; void **p0; dyn_array_init (&da->array); p0 = dyn_array_add (&da->array, sizeof (void*)); *p0 = ptr0; p = dyn_array_add (&da->array, sizeof (void*)); } else #endif { p = dyn_array_add (&da->array, sizeof (void*)); } *p = ptr; }
static void dyn_array_int_init (DynArray *da) { dyn_array_init (da, sizeof (int)); }
static void dyn_array_ptr_init (DynArray *da) { dyn_array_init (da, sizeof (void*)); }
static void dyn_array_scc_init (DynSCCArray *da) { dyn_array_init (&da->array); }
static void dyn_array_ptr_init (DynPtrArray *da) { dyn_array_init (&da->array); }
/* int */ static void dyn_array_int_init (DynIntArray *da) { dyn_array_init (&da->array); }