version 1.2.4.2, 2011/05/19 03:01:20
|
version 1.3, 2011/06/07 11:49:39
|
Line 128 io_arrayTo(array_t * __restrict arr)
|
Line 128 io_arrayTo(array_t * __restrict arr)
|
if (!arr || !io_arraySize(arr)) |
if (!arr || !io_arraySize(arr)) |
return NULL; |
return NULL; |
|
|
args = (char **) calloc(io_arraySize(arr), sizeof(char*)); | args = (char **) calloc(io_arraySize(arr) + 1, sizeof(char*)); |
if (!args) { |
if (!args) { |
LOGERR; |
LOGERR; |
return NULL; |
return NULL; |
} else |
} else |
memcpy(args, arr->arr_data, io_arraySize(arr) * sizeof(char*)); |
memcpy(args, arr->arr_data, io_arraySize(arr) * sizeof(char*)); |
|
args[io_arraySize(arr)] = NULL; |
|
|
return args; |
return args; |
} |
} |
Line 225 io_arrayGrow(array_t * __restrict arr, int newNumItems
|
Line 226 io_arrayGrow(array_t * __restrict arr, int newNumItems
|
*/ |
*/ |
|
|
arr->arr_num = newNumItems; |
arr->arr_num = newNumItems; |
data = realloc(arr->arr_data, io_arraySize(arr) * sizeof(void*)); | if (io_arraySize(arr)) { |
if (!data) { | data = realloc(arr->arr_data, io_arraySize(arr) * sizeof(void*)); |
LOGERR; | if (!data) { |
return -1; | LOGERR; |
} else | return -1; |
arr->arr_data = data; | } else |
memset(arr->arr_data + (io_arraySize(arr) - n), 0, n * sizeof(void*)); | arr->arr_data = data; |
| |
| memset(arr->arr_data + (io_arraySize(arr) - n), 0, n * sizeof(void*)); |
| } else { |
| if (arr->arr_data) |
| free(arr->arr_data); |
| arr->arr_data = NULL; |
| } |
|
|
return 0; |
return 0; |
} |
} |