--- libelwix/src/array.c 2013/05/30 09:07:33 1.2 +++ libelwix/src/array.c 2019/01/21 11:56:39 1.5.36.1 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: array.c,v 1.2 2013/05/30 09:07:33 misho Exp $ +* $Id: array.c,v 1.5.36.1 2019/01/21 11:56:39 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, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 +Copyright 2004 - 2019 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -173,6 +173,30 @@ array_Destroy(array_t ** __restrict parr) } /* + * array_Reset() - Reset array to initial state + * + * @parr = Array + * @purge = Purge data, if <>0 then will be free entire data memory + * return: none + */ +void +array_Reset(array_t * __restrict arr, int purge) +{ + if (!arr) + return; + + arr->arr_last = -1; + arr->arr_num = 0; + + if (purge && arr->arr_data) { + e_free(arr->arr_data); + arr->arr_data = e_calloc(array_Size(arr), sizeof(intptr_t)); + } + + array_Zero(arr); +} + +/* * array_Len() - Get last used element in dynamic array (array Length) * * @arr = Array @@ -319,7 +343,7 @@ array_Concat(array_t * __restrict dest, array_t * __re /* * 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 * return: -1 error; >0 count of destination array */ @@ -422,7 +446,7 @@ array_Pop(array_t * __restrict arr, void ** __restrict /* * 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!!! * @nargs = Maximum requested count of arguments from input string psArgs, if 0 all psArgs