--- libaitio/src/Attic/sarray.c 2011/05/03 14:45:55 1.1.2.3 +++ libaitio/src/Attic/sarray.c 2011/05/03 15:33:54 1.1.2.5 @@ -156,6 +156,25 @@ io_sarrGet(sarr_t * __restrict arr, u_int idx) } /* + * io_sarrGet2() - Always get element from dynamic split-order array + * Function automatic grow array. Good use for Hash tables! + * @arr = Array + * @idx = Index (warning 1st element is at position 1) + * return: NULL not found, !=NULL element + */ +void * +io_sarrGet2(sarr_t * __restrict arr, u_int idx) +{ + assert(arr); + if (!arr || idx < 1) + return NULL; + if (arr->sarr_num < idx) + if (io_sarrGrow(arr, idx)) + return NULL; + return io_sarrGet(arr, idx); +} + +/* * io_sarrSet() - Set element to dynamic split-order array * @arr = Array * @idx = Index (warning 1st element is at position 1) @@ -181,6 +200,7 @@ io_sarrSet(sarr_t * __restrict arr, u_int idx, void *d return ret; } else memset(seg, 0, arr->sarr_seg * sizeof(void*)); + arr->sarr_data[idx / arr->sarr_seg] = seg; } pos = idx % arr->sarr_seg;