version 1.5.36.1, 2019/01/21 11:56:39
|
version 1.8.4.2, 2019/01/23 17:40:37
|
Line 68 array_Init(int numItems)
|
Line 68 array_Init(int numItems)
|
e_free(arr); |
e_free(arr); |
return NULL; |
return NULL; |
} else |
} else |
array_Zero(arr); | memset(arr->arr_data, 0, array_Size(arr) * sizeof(intptr_t)); |
|
|
return arr; |
return arr; |
} |
} |
|
|
/* |
/* |
|
* array_Init2() - Initialize dynamic array |
|
* |
|
* @arr = Allocated array variable |
|
* @numItems = Number of Items |
|
* return: NULL error, != NULL allocated memory for array |
|
*/ |
|
array_t * |
|
array_Init2(array_t * __restrict arr, int numItems) |
|
{ |
|
if (!arr) |
|
return array_Init(numItems); |
|
|
|
if (array_Size(arr)) |
|
return NULL; /* already allocated array! */ |
|
|
|
arr->arr_last = -1; |
|
arr->arr_num = numItems; |
|
arr->arr_data = e_calloc(array_Size(arr), sizeof(intptr_t)); |
|
if (!arr->arr_data) { |
|
e_free(arr); |
|
return NULL; |
|
} else |
|
memset(arr->arr_data, 0, array_Size(arr) * sizeof(intptr_t)); |
|
|
|
return arr; |
|
} |
|
|
|
|
|
/* |
* array_From() - Create and fill array from array with pointers |
* array_From() - Create and fill array from array with pointers |
* |
* |
* @pargv = Array with pointers |
* @pargv = Array with pointers |
Line 146 array_Free(array_t * __restrict arr)
|
Line 175 array_Free(array_t * __restrict arr)
|
return; |
return; |
|
|
for (i = 0; i < array_Size(arr); i++) |
for (i = 0; i < array_Size(arr); i++) |
if (arr->arr_data[i]) { | if (arr->arr_data[i]) |
e_free(arr->arr_data[i]); |
e_free(arr->arr_data[i]); |
arr->arr_data[i] = NULL; |
|
} |
|
|
|
arr->arr_last = -1; | array_Zero(arr); |
} |
} |
|
|
/* |
/* |
Line 173 array_Destroy(array_t ** __restrict parr)
|
Line 200 array_Destroy(array_t ** __restrict parr)
|
} |
} |
|
|
/* |
/* |
|
* array_Destroy2() - Free data in dynamic array |
|
* |
|
* @parr = Array |
|
* return: none |
|
*/ |
|
void |
|
array_Destroy2(array_t * __restrict arr) |
|
{ |
|
if (!arr) |
|
return; |
|
|
|
if (arr->arr_data) |
|
e_free(arr->arr_data); |
|
memset(arr, 0, sizeof(array_t)); |
|
} |
|
/* |
* array_Reset() - Reset array to initial state |
* array_Reset() - Reset array to initial state |
* |
* |
* @parr = Array |
* @parr = Array |
* @purge = Purge data, if <>0 then will be free entire data memory | * @purge = Purge all data, if <>0 then will be free entire data memory |
* return: none |
* return: none |
*/ |
*/ |
void |
void |
Line 185 array_Reset(array_t * __restrict arr, int purge)
|
Line 228 array_Reset(array_t * __restrict arr, int purge)
|
if (!arr) |
if (!arr) |
return; |
return; |
|
|
arr->arr_last = -1; |
|
arr->arr_num = 0; |
|
|
|
if (purge && arr->arr_data) { |
if (purge && arr->arr_data) { |
e_free(arr->arr_data); |
e_free(arr->arr_data); |
|
arr->arr_num = 0; |
arr->arr_data = e_calloc(array_Size(arr), sizeof(intptr_t)); |
arr->arr_data = e_calloc(array_Size(arr), sizeof(intptr_t)); |
} |
} |
|
|