version 1.6, 2012/03/29 01:31:34
|
version 1.6.8.2, 2012/05/23 14:06:08
|
Line 61 io_sarrInit(int numItems, int segLen)
|
Line 61 io_sarrInit(int numItems, int segLen)
|
if (segLen < 1) |
if (segLen < 1) |
return NULL; |
return NULL; |
|
|
arr = malloc(sizeof(sarr_t)); | arr = io_malloc(sizeof(sarr_t)); |
if (!arr) { |
if (!arr) { |
LOGERR; |
LOGERR; |
return NULL; |
return NULL; |
Line 70 io_sarrInit(int numItems, int segLen)
|
Line 70 io_sarrInit(int numItems, int segLen)
|
arr->sarr_num = numItems; |
arr->sarr_num = numItems; |
arr->sarr_seg = segLen; |
arr->sarr_seg = segLen; |
arr->sarr_siz = numItems / segLen + 1; |
arr->sarr_siz = numItems / segLen + 1; |
arr->sarr_data = calloc(arr->sarr_siz, sizeof(sarr_seg_t)); | arr->sarr_data = io_calloc(arr->sarr_siz, sizeof(sarr_seg_t)); |
if (!arr->sarr_data) { |
if (!arr->sarr_data) { |
LOGERR; |
LOGERR; |
free(arr); | io_free(arr); |
return NULL; |
return NULL; |
} else |
} else |
memset(arr->sarr_data, 0, arr->sarr_siz * sizeof(sarr_seg_t)); |
memset(arr->sarr_data, 0, arr->sarr_siz * sizeof(sarr_seg_t)); |
Line 97 io_sarrDestroy(sarr_t ** __restrict parr)
|
Line 97 io_sarrDestroy(sarr_t ** __restrict parr)
|
|
|
for (i = 0; i < (*parr)->sarr_siz; i++) |
for (i = 0; i < (*parr)->sarr_siz; i++) |
if ((*parr)->sarr_data[i]) { |
if ((*parr)->sarr_data[i]) { |
free((*parr)->sarr_data[i]); | io_free((*parr)->sarr_data[i]); |
(*parr)->sarr_data[i] = NULL; |
(*parr)->sarr_data[i] = NULL; |
} |
} |
|
|
if ((*parr)->sarr_data) |
if ((*parr)->sarr_data) |
free((*parr)->sarr_data); | io_free((*parr)->sarr_data); |
free(*parr); | io_free(*parr); |
*parr = NULL; |
*parr = NULL; |
} |
} |
|
|
Line 152 io_sarrVacuum(sarr_t * __restrict arr)
|
Line 152 io_sarrVacuum(sarr_t * __restrict arr)
|
if (seg[j]) |
if (seg[j]) |
break; |
break; |
if (j == arr->sarr_seg) { |
if (j == arr->sarr_seg) { |
free(arr->sarr_data[i]); | io_free(arr->sarr_data[i]); |
arr->sarr_data[i] = NULL; |
arr->sarr_data[i] = NULL; |
cx++; |
cx++; |
} |
} |
Line 187 io_sarrGrow(sarr_t * __restrict arr, int newNumItems)
|
Line 187 io_sarrGrow(sarr_t * __restrict arr, int newNumItems)
|
else |
else |
for (i = seg; i < arr->sarr_siz; i++) |
for (i = seg; i < arr->sarr_siz; i++) |
if (arr->sarr_data[i]) |
if (arr->sarr_data[i]) |
free(arr->sarr_data[i]); | io_free(arr->sarr_data[i]); |
|
|
arr->sarr_siz = seg; |
arr->sarr_siz = seg; |
data = realloc(arr->sarr_data, arr->sarr_siz * sizeof(sarr_seg_t)); | data = io_realloc(arr->sarr_data, arr->sarr_siz * sizeof(sarr_seg_t)); |
if (!data) { |
if (!data) { |
LOGERR; |
LOGERR; |
return -1; |
return -1; |
Line 263 io_sarrSet(sarr_t * __restrict arr, u_int idx, void *d
|
Line 263 io_sarrSet(sarr_t * __restrict arr, u_int idx, void *d
|
|
|
seg = arr->sarr_data[idx / arr->sarr_seg]; |
seg = arr->sarr_data[idx / arr->sarr_seg]; |
if (!seg) { |
if (!seg) { |
seg = calloc(arr->sarr_seg, sizeof(void*)); | seg = io_calloc(arr->sarr_seg, sizeof(void*)); |
if (!seg) { |
if (!seg) { |
LOGERR; |
LOGERR; |
return ret; |
return ret; |
Line 306 io_sarr2array(sarr_t ** __restrict sa, int sarrFree)
|
Line 306 io_sarr2array(sarr_t ** __restrict sa, int sarrFree)
|
io_arraySet(arr, i, io_sarrGet(*sa, i + 1)); |
io_arraySet(arr, i, io_sarrGet(*sa, i + 1)); |
|
|
if (sarrFree) { |
if (sarrFree) { |
free(*sa); | io_free(*sa); |
*sa = NULL; |
*sa = NULL; |
} |
} |
return arr; |
return arr; |
Line 340 io_array2sarr(array_t ** __restrict a, int segLen, int
|
Line 340 io_array2sarr(array_t ** __restrict a, int segLen, int
|
io_sarrSet(sa, i + 1, io_arrayGet(*a, i)); |
io_sarrSet(sa, i + 1, io_arrayGet(*a, i)); |
|
|
if (arrFree) { |
if (arrFree) { |
free(*a); | io_free(*a); |
*a = NULL; |
*a = NULL; |
} |
} |
return sa; |
return sa; |