version 1.2.2.1, 2011/05/03 15:44:58
|
version 1.3.2.3, 2011/08/26 13:19:35
|
Line 90 io_sarrDestroy(sarr_t ** __restrict parr)
|
Line 90 io_sarrDestroy(sarr_t ** __restrict parr)
|
{ |
{ |
register int i; |
register int i; |
|
|
assert(parr); | assert(parr && *parr); |
if (!parr) | if (!parr || !*parr) |
return; |
return; |
|
|
for (i = 0; i < (*parr)->sarr_siz; i++) |
for (i = 0; i < (*parr)->sarr_siz; i++) |
Line 253 io_sarrSet(sarr_t * __restrict arr, u_int idx, void *d
|
Line 253 io_sarrSet(sarr_t * __restrict arr, u_int idx, void *d
|
seg[pos] = data; |
seg[pos] = data; |
|
|
return ret; |
return ret; |
|
} |
|
|
|
/* |
|
* io_sarr2array() - Convert from split-order array to dynamic array |
|
* @sa = split array |
|
* @sarrFree = after convert split array !=0 will be destroyed sarray |
|
* return: NULL error or != NULL new array |
|
*/ |
|
array_t * |
|
io_sarr2array(sarr_t ** __restrict sa, int sarrFree) |
|
{ |
|
array_t *arr = NULL; |
|
int el; |
|
register int i; |
|
|
|
assert(sa && *sa); |
|
if (!sa || !*sa) |
|
return NULL; |
|
|
|
el = io_sarrSize(*sa); |
|
arr = io_arrayInit(el); |
|
if (!arr) |
|
return NULL; |
|
|
|
for (i = 0; i < el; i++) |
|
io_arraySet(arr, i, io_sarrGet(*sa, i + 1)); |
|
|
|
if (sarrFree) { |
|
free(*sa); |
|
*sa = NULL; |
|
} |
|
return arr; |
|
} |
|
|
|
/* |
|
* io_array2sarr() - Convert from dynamic array to split-order array |
|
* @a = array |
|
* @segLen = Length of segment |
|
* @arrFree = after convert array !=0 will be destroyed |
|
* return: NULL error or != NULL new sarr |
|
*/ |
|
sarr_t * |
|
io_array2sarr(array_t ** __restrict a, int segLen, int arrFree) |
|
{ |
|
sarr_t *sa = NULL; |
|
int el; |
|
register int i; |
|
|
|
assert(a && *a); |
|
if (!a || !*a) |
|
return NULL; |
|
|
|
el = io_arraySize(*a); |
|
sa = io_sarrInit(el, segLen); |
|
if (!sa) |
|
return NULL; |
|
|
|
for (i = 0; i < el; i++) |
|
io_sarrSet(sa, i + 1, io_arrayGet(*a, i)); |
|
|
|
if (arrFree) { |
|
free(*a); |
|
*a = NULL; |
|
} |
|
return sa; |
} |
} |