--- libelwix/inc/elwix/aarray.h 2018/05/28 22:56:23 1.7 +++ libelwix/inc/elwix/aarray.h 2019/01/23 18:22:41 1.10 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aarray.h,v 1.7 2018/05/28 22:56:23 misho Exp $ +* $Id: aarray.h,v 1.10 2019/01/23 18:22:41 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004 - 2018 +Copyright 2004 - 2019 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -55,8 +55,8 @@ typedef struct _tagArray { #define array_Size(_arr) ((_arr) ? (_arr)->arr_num : 0) #define array_Last(_arr) (array_Size((_arr)) ? (_arr)->arr_last : -1) -#define array_Zero(_arr) (assert((_arr)), memset((_arr)->arr_data, 0, \ - array_Size((_arr)) * sizeof(intptr_t))) +#define array_Zero(_arr) (assert((_arr)), (_arr)->arr_last = -1, \ + memset((_arr)->arr_data, 0, array_Size((_arr)) * sizeof(intptr_t))) #define array_Ptr(_arr, _d) ((_arr) ? (_arr)->arr_data[_d] : NULL) #define array_Get2(_arr, _d) (assert((_arr) && (_arr)->arr_num > _d), ((_arr)->arr_data + _d)) @@ -81,6 +81,14 @@ typedef struct _tagArray { */ array_t *array_Init(int numItems); /* + * 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); +/* * array_Destroy() - Free and destroy dynamic array * * @parr = Array @@ -88,6 +96,13 @@ array_t *array_Init(int numItems); */ void array_Destroy(array_t ** __restrict parr); /* + * array_Destroy2() - Free data in dynamic array + * + * @parr = Array + * return: none + */ +void array_Destroy2(array_t * __restrict arr); +/* * array_Free() - Free all data in dynamic array items * (WARNING! If assign static array dont use this!!!) * @@ -95,6 +110,14 @@ void array_Destroy(array_t ** __restrict parr); * return: none */ void array_Free(array_t * __restrict arr); +/* + * 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); /* * array_From() - Create and fill array from array with pointers