--- libaitio/inc/aitio.h 2012/04/05 12:21:14 1.16.2.9 +++ libaitio/inc/aitio.h 2012/04/10 15:27:33 1.16.2.10 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitio.h,v 1.16.2.9 2012/04/05 12:21:14 misho Exp $ +* $Id: aitio.h,v 1.16.2.10 2012/04/10 15:27:33 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -74,6 +74,7 @@ typedef struct _tagSplitArray { } sarr_t; typedef struct _tagArray { + int arr_last; int arr_num; void **arr_data; } array_t; @@ -558,7 +559,7 @@ inline char **io_arrayTo(array_t * __restrict arr); * io_arrayLen() - Get last used element in dynamic array (array Length) * * @arr = Array - * return: -1 error, 0 empty or >0 position of last used element + * return: -1 empty or >-1 position of last used element */ inline int io_arrayLen(array_t * __restrict arr); /* @@ -596,6 +597,7 @@ int io_arrayGrow(array_t * __restrict arr, int newNumI int io_arrayVacuum(array_t * __restrict arr, int fromWhere); #define io_arraySize(_arr) ((_arr) ? (_arr)->arr_num : 0) +#define io_arrayLast(_arr) ((_arr) ? (_arr)->arr_last : -1) #define io_arrayZero(_arr) (assert((_arr)), memset((_arr)->arr_data, 0, \ io_arraySize((_arr)) * sizeof(void*))) @@ -604,6 +606,8 @@ int io_arrayVacuum(array_t * __restrict arr, int fromW ((_type) *((_arr)->arr_data + _d))) #define io_arraySet(_arr, _d, _ptr) do { \ assert((_arr) && (_arr)->arr_num > _d); \ + if ((_arr)->arr_last < _d) \ + (_arr)->arr_last = _d; \ *((_arr)->arr_data + _d) = (void*) (_ptr); \ } while (0) #define io_arrayDel(_arr, _d, _fri) do { \ @@ -627,9 +631,10 @@ inline void *io_arrayElem(array_t * __restrict arr, in * * @arr = Array * @data = Element, if set NULL return only first empty position + * @mayGrow = Array may to grow, if not enough room for new element * return: -1 not found empty position, array is full!, >-1 return position of stored element into array */ -inline int io_arrayPush(array_t * __restrict arr, void **data); +inline int io_arrayPush(array_t * __restrict arr, void **data, int mayGrow); /* * io_arrayPop() - Pop element from dynamic array like stack manner, last used position *