/* * Returns an entry that has been displaced, if any. */ Array_item *BX_add_to_array (Array *array, Array_item *item) { int count; int location = 0; Array_item *ret = NULL; u_32int_t mask; /* Dummy var */ if (array->hash == HASH_INSENSITIVE) item->hash = ci_alist_hash(item->name, &mask); else item->hash = cs_alist_hash(item->name, &mask); check_array_size(array); if (array->max) { find_array_item(array, item->name, &count, &location); if (count < 0) { ret = ARRAY_ITEM(array, location); array->max--; } else move_array_items(array, location, array->max, 1); } array->list[location] = item; array->max++; return ret; }
Array_item *add_to_array (Array *array, Array_item *item) { int count; int location = 0; Array_item *ret = (void *) 0 ; u_32int_t mask; if (array->hash == HASH_INSENSITIVE) item->hash = ci_alist_hash(item->name, &mask); else item->hash = cs_alist_hash(item->name, &mask); check_array_size(array); if (array->max) { find_array_item(array, item->name, &count, &location); if (count < 0) { ret = ((Array_item *) (( array ) -> list [ ( location ) ])) ; array->max--; } else move_array_items(array, location, array->max, 1); } array->list[location] = item; array->max++; return ret; }
/* Remove the 'which'th item from the given array */ Array_item *BX_array_pop (Array *array, int which) { Array_item *ret = NULL; if (which < 0 || which >= array->max) return NULL; ret = ARRAY_ITEM(array, which); move_array_items(array, which + 1, array->max, -1); array->max--; return ret; }
Array_item *array_pop (Array *array, int which) { Array_item *ret = (void *) 0 ; if (which < 0 || which >= array->max) return (void *) 0 ; ret = ((Array_item *) (( array ) -> list [ ( which ) ])) ; move_array_items(array, which + 1, array->max, -1); array->max--; return ret; }
/* Remove the 'which'th item from the given array */ array_item *array_pop (array *a, int which) { array_item *ret = NULL; if (which < 0 || which >= a->max) return NULL; ret = ARRAY_ITEM(a, which); move_array_items(a, which + 1, a->max, -1); a->max--; check_array_size(a); return ret; }
/* * Returns the entry that has been removed, if any. */ Array_item *BX_remove_all_from_array (Array *array, char *name) { int count, location = 0; Array_item *ret = NULL; if (array->max) { find_array_item(array, name, &count, &location); if (count == 0) return NULL; ret = ARRAY_ITEM(array, location); move_array_items(array, location + 1, array->max, -1); array->max--; return ret; } return NULL; /* Cant delete whats not there */ }
Array_item *remove_all_from_array (Array *array, char *name) { int count, location = 0; Array_item *ret = (void *) 0 ; if (array->max) { find_array_item(array, name, &count, &location); if (count == 0) return (void *) 0 ; ret = ((Array_item *) (( array ) -> list [ ( location ) ])) ; move_array_items(array, location + 1, array->max, -1); array->max--; return ret; } return (void *) 0 ; }