|
|
| version 1.9, 2012/05/14 12:49:21 | version 1.10.6.2, 2012/07/30 10:55:51 |
|---|---|
| Line 57 io_arrayInit(int numItems) | Line 57 io_arrayInit(int numItems) |
| { | { |
| array_t *arr = NULL; | array_t *arr = NULL; |
| arr = malloc(sizeof(array_t)); | arr = io_malloc(sizeof(array_t)); |
| if (!arr) { | if (!arr) { |
| LOGERR; | LOGERR; |
| return NULL; | return NULL; |
| Line 65 io_arrayInit(int numItems) | Line 65 io_arrayInit(int numItems) |
| arr->arr_last = -1; | arr->arr_last = -1; |
| arr->arr_num = numItems; | arr->arr_num = numItems; |
| arr->arr_data = calloc(io_arraySize(arr), sizeof(void*)); | arr->arr_data = io_calloc(io_arraySize(arr), sizeof(void*)); |
| if (!arr->arr_data) { | if (!arr->arr_data) { |
| LOGERR; | LOGERR; |
| free(arr); | io_free(arr); |
| return NULL; | return NULL; |
| } else | } else |
| io_arrayZero(arr); | io_arrayZero(arr); |
| Line 99 io_arrayFrom(const char *** __restrict pargv, int argc | Line 99 io_arrayFrom(const char *** __restrict pargv, int argc |
| else | else |
| for (a = *pargv; *a; a++, num++); | for (a = *pargv; *a; a++, num++); |
| arr = malloc(sizeof(array_t)); | arr = io_malloc(sizeof(array_t)); |
| if (!arr) { | if (!arr) { |
| LOGERR; | LOGERR; |
| return NULL; | return NULL; |
| } | } |
| arr->arr_num = num; | arr->arr_num = num; |
| arr->arr_data = calloc(io_arraySize(arr), sizeof(void*)); | arr->arr_data = io_calloc(io_arraySize(arr), sizeof(void*)); |
| if (!arr->arr_data) { | if (!arr->arr_data) { |
| LOGERR; | LOGERR; |
| free(arr); | io_free(arr); |
| return NULL; | return NULL; |
| } else { | } else { |
| memcpy(arr->arr_data, *pargv, io_arraySize(arr) * sizeof(void*)); | memcpy(arr->arr_data, *pargv, io_arraySize(arr) * sizeof(void*)); |
| Line 134 io_arrayTo(array_t * __restrict arr) | Line 134 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) + 1, sizeof(char*)); | args = (char **) io_calloc(io_arraySize(arr) + 1, sizeof(char*)); |
| if (!args) { | if (!args) { |
| LOGERR; | LOGERR; |
| return NULL; | return NULL; |
| Line 162 io_arrayFree(array_t * __restrict arr) | Line 162 io_arrayFree(array_t * __restrict arr) |
| for (i = 0; i < io_arraySize(arr); i++) | for (i = 0; i < io_arraySize(arr); i++) |
| if (arr->arr_data[i]) { | if (arr->arr_data[i]) { |
| free(arr->arr_data[i]); | io_free(arr->arr_data[i]); |
| arr->arr_data[i] = NULL; | arr->arr_data[i] = NULL; |
| } | } |
| Line 182 io_arrayDestroy(array_t ** __restrict parr) | Line 182 io_arrayDestroy(array_t ** __restrict parr) |
| return; | return; |
| if ((*parr)->arr_data) | if ((*parr)->arr_data) |
| free((*parr)->arr_data); | io_free((*parr)->arr_data); |
| free(*parr); | io_free(*parr); |
| *parr = NULL; | *parr = NULL; |
| } | } |
| Line 232 io_arrayGrow(array_t * __restrict arr, int newNumItems | Line 232 io_arrayGrow(array_t * __restrict arr, int newNumItems |
| } else if (freeShrink) | } else if (freeShrink) |
| for (i = newNumItems; i < arr->arr_num; i++) | for (i = newNumItems; i < arr->arr_num; i++) |
| if (arr->arr_data[i]) | if (arr->arr_data[i]) |
| free(arr->arr_data[i]); | io_free(arr->arr_data[i]); |
| arr->arr_num = newNumItems; | arr->arr_num = newNumItems; |
| if (io_arraySize(arr)) { | if (io_arraySize(arr)) { |
| data = realloc(arr->arr_data, io_arraySize(arr) * sizeof(void*)); | data = io_realloc(arr->arr_data, io_arraySize(arr) * sizeof(void*)); |
| if (!data) { | if (!data) { |
| LOGERR; | LOGERR; |
| return -1; | return -1; |
| Line 247 io_arrayGrow(array_t * __restrict arr, int newNumItems | Line 247 io_arrayGrow(array_t * __restrict arr, int newNumItems |
| arr->arr_last = io_arrayLen(arr); | arr->arr_last = io_arrayLen(arr); |
| } else { | } else { |
| if (arr->arr_data) | if (arr->arr_data) |
| free(arr->arr_data); | io_free(arr->arr_data); |
| arr->arr_data = NULL; | arr->arr_data = NULL; |
| arr->arr_last = -1; | arr->arr_last = -1; |
| } | } |
| Line 549 io_MakeAV(const char * __restrict csArgs, const char * | Line 549 io_MakeAV(const char * __restrict csArgs, const char * |
| return -1; | return -1; |
| else | else |
| memset(psValue, 0, valLen); | memset(psValue, 0, valLen); |
| psBuf = strdup(csArgs); | psBuf = io_strdup(csArgs); |
| if (!psBuf) { | if (!psBuf) { |
| LOGERR; | LOGERR; |
| return -1; | return -1; |
| Line 567 io_MakeAV(const char * __restrict csArgs, const char * | Line 567 io_MakeAV(const char * __restrict csArgs, const char * |
| strlcpy(psValue, pos, valLen); | strlcpy(psValue, pos, valLen); |
| } | } |
| free(psBuf); | io_free(psBuf); |
| return ret; | return ret; |
| } | } |
| /* | |
| * io_MakeAV2() Parse and make attribute/value pair over input string | |
| * | |
| * @csArgs = Input argument line, will be modified! | |
| * @csDelim = Delimiter for separate | |
| * @psAttr = Output Attribute | |
| * @psValue = Output Value, if ==NULL this element not present value or not wanted for return | |
| * return: 0 error format; -1 error:: can`t read; >0 ok, number of readed items | |
| */ | |
| int | |
| io_MakeAV2(char * __restrict psArgs, const char *csDelim, | |
| char * __restrict psAttr, char * __restrict psValue) | |
| { | |
| register int ret = 0; | |
| char *pos; | |
| if (!psArgs || !csDelim) | |
| return -1; | |
| pos = strpbrk(psArgs, csDelim); | |
| if (pos) | |
| *pos++ = 0; | |
| ret++; | |
| if (psAttr) | |
| psAttr = psArgs; | |
| if (psValue) { | |
| if (pos && *pos) { | |
| ret++; | |
| psValue = pos; | |
| } else | |
| psValue = NULL; | |
| } | |
| return ret; | |
| } |