--- libelwix/src/array.c 2013/03/19 17:02:12 1.1.1.1.6.1 +++ libelwix/src/array.c 2013/03/25 10:46:41 1.1.1.1.6.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: array.c,v 1.1.1.1.6.1 2013/03/19 17:02:12 misho Exp $ +* $Id: array.c,v 1.1.1.1.6.2 2013/03/25 10:46:41 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -387,9 +387,8 @@ array_Push(array_t * __restrict arr, void *data, int n if (!nogrow && ret >= array_Size(arr) && array_Grow(arr, ret + 1, 0)) return -1; - ret = arr->arr_last++; - if (data) - arr->arr_data[arr->arr_last] = data; + ret = ++arr->arr_last; + arr->arr_data[arr->arr_last] = data; return ret; } @@ -410,12 +409,13 @@ array_Pop(array_t * __restrict arr, void ** __restrict if (!arr) return -1; - ret = array_Last(arr); - - if (data) - *data = arr->arr_data[ret]; - if (!nodel) - arr->arr_data[arr->arr_last--] = NULL; + if ((ret = array_Last(arr)) != -1) { + if (data) + *data = arr->arr_data[arr->arr_last]; + if (!nodel) + arr->arr_data[arr->arr_last] = NULL; + arr->arr_last--; + } return ret; }