version 1.1.1.1.6.3, 2013/05/26 20:03:19
|
version 1.9.46.1, 2024/10/27 04:27:51
|
Line 12 terms:
|
Line 12 terms:
|
All of the documentation and software included in the ELWIX and AITNET |
All of the documentation and software included in the ELWIX and AITNET |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
|
|
Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 | Copyright 2004 - 2024 |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
|
|
Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
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 |
|
* |
|
* @parr = Array |
|
* @purge = Purge all data, if <>0 then will be free entire data memory |
|
* return: none |
|
*/ |
|
void |
|
array_Reset(array_t * __restrict arr, int purge) |
|
{ |
|
if (!arr) |
|
return; |
|
|
|
if (purge && arr->arr_data) { |
|
e_free(arr->arr_data); |
|
arr->arr_num = 0; |
|
arr->arr_data = e_calloc(array_Size(arr), sizeof(intptr_t)); |
|
} |
|
|
|
if (arr->arr_data) |
|
array_Zero(arr); |
|
} |
|
|
|
/* |
* array_Len() - Get last used element in dynamic array (array Length) |
* array_Len() - Get last used element in dynamic array (array Length) |
* |
* |
* @arr = Array |
* @arr = Array |
Line 310 array_Concat(array_t * __restrict dest, array_t * __re
|
Line 376 array_Concat(array_t * __restrict dest, array_t * __re
|
n = array_Size(dest); |
n = array_Size(dest); |
if (array_Grow(dest, n + array_Size(src), 0)) |
if (array_Grow(dest, n + array_Size(src), 0)) |
return -1; |
return -1; |
|
if (!dest->arr_data) |
|
return -1; |
memcpy(dest->arr_data + n, src->arr_data, array_Size(src) * sizeof(intptr_t)); |
memcpy(dest->arr_data + n, src->arr_data, array_Size(src) * sizeof(intptr_t)); |
|
|
dest->arr_last = array_Len(dest); |
dest->arr_last = array_Len(dest); |
Line 319 array_Concat(array_t * __restrict dest, array_t * __re
|
Line 387 array_Concat(array_t * __restrict dest, array_t * __re
|
/* |
/* |
* array_Copy() Copy source array to destination array |
* array_Copy() Copy source array to destination array |
* |
* |
* @dest = Destination array, after use free with io_arrayDestroy() | * @dest = Destination array, after use free with array_Destroy() |
* @src = Source array |
* @src = Source array |
* return: -1 error; >0 count of destination array |
* return: -1 error; >0 count of destination array |
*/ |
*/ |
Line 357 array_Elem(array_t * __restrict arr, int n, void *data
|
Line 425 array_Elem(array_t * __restrict arr, int n, void *data
|
|
|
if (n >= array_Size(arr) && array_Grow(arr, n + 1, 0)) |
if (n >= array_Size(arr) && array_Grow(arr, n + 1, 0)) |
return (void*) -1; |
return (void*) -1; |
|
if (!arr->arr_data) |
|
return (void*) -1; |
|
|
dat = array_Get(arr, n); |
dat = array_Get(arr, n); |
if (data) |
if (data) |
Line 386 array_Push(array_t * __restrict arr, void *data, int n
|
Line 456 array_Push(array_t * __restrict arr, void *data, int n
|
return -1; |
return -1; |
if (!nogrow && ret >= array_Size(arr) && array_Grow(arr, ret + 1, 0)) |
if (!nogrow && ret >= array_Size(arr) && array_Grow(arr, ret + 1, 0)) |
return -1; |
return -1; |
|
if (!arr->arr_data) |
|
return -1; |
|
|
ret = ++arr->arr_last; |
ret = ++arr->arr_last; |
arr->arr_data[arr->arr_last] = data; |
arr->arr_data[arr->arr_last] = data; |
Line 422 array_Pop(array_t * __restrict arr, void ** __restrict
|
Line 494 array_Pop(array_t * __restrict arr, void ** __restrict
|
|
|
/* |
/* |
* array_Args() Parse and make array from arguments ... (input string will be modified!!! |
* array_Args() Parse and make array from arguments ... (input string will be modified!!! |
* and output array must be free with io_arrayDestroy() after use!) | * and output array must be free with array_Destroy() after use!) |
* |
* |
* @psArgs = Input arguments line, after execute string is modified!!! |
* @psArgs = Input arguments line, after execute string is modified!!! |
* @nargs = Maximum requested count of arguments from input string psArgs, if 0 all psArgs |
* @nargs = Maximum requested count of arguments from input string psArgs, if 0 all psArgs |