--- libaitio/src/Attic/vars.c 2012/05/18 12:43:06 1.7.2.2 +++ libaitio/src/Attic/vars.c 2012/05/18 13:37:48 1.7.2.4 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: vars.c,v 1.7.2.2 2012/05/18 12:43:06 misho Exp $ +* $Id: vars.c,v 1.7.2.4 2012/05/18 13:37:48 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -499,24 +499,29 @@ io_allocVars(int varnum) * return: NULL error or !=NULL ait_val_t element */ inline ait_val_t * -io_getVars(array_t * __restrict vars, int n) +io_getVars(array_t ** __restrict vars, int n) { ait_val_t *v; - if (!vars) { - if (!(vars = io_arrayInit(n + 1))) + if (!vars) + return NULL; + + if (!*vars) { + if (!(*vars = io_arrayInit(n + 1))) return NULL; } else { - if (n >= io_arraySize(vars) && io_arrayGrow(vars, n + 1, 0)) - return NULL; + if (n >= io_arraySize(*vars)) { + if (io_arrayGrow(*vars, n + 1, 0)) + return NULL; + if ((v = io_allocVar())) + return NULL; + else + io_arraySet(*vars, n, v); + return v; + } } - if ((v = io_allocVar())) - return NULL; - else - io_arraySet(vars, n, v); - - return v; + return io_array(*vars, n, ait_val_t*); } /*