--- libaitwww/src/tools.c 2012/07/31 11:56:16 1.2.6.1 +++ libaitwww/src/tools.c 2012/07/31 22:59:33 1.2.6.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: tools.c,v 1.2.6.1 2012/07/31 11:56:16 misho Exp $ +* $Id: tools.c,v 1.2.6.2 2012/07/31 22:59:33 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -103,30 +103,31 @@ www_cmptype(const char *ct, const char *type) * * @str = query string * @delim = delimiter - * return: NULL error or AV pair, must be free() after use! + * return: NULL error or AV pair, must be io_free() after use! */ -char * +ait_val_t * www_getpair(char ** __restrict str, const char *delim) { - char *tr, *s = NULL; + char *tr; int cx; + ait_val_t *s; assert(str && *str && delim); + s = io_allocVar(); + if (!s) { + www_SetErr(io_GetErrno(), "%s", io_GetError()); + return NULL; + } + cx = strcspn(*str, delim); tr = *str + cx; + if (*tr) + *tr++ = 0; - s = malloc(cx + 1); - if (!s) { - LOGERR; - return NULL; - } else - strlcpy(s, *str, cx + 1); + AIT_SET_STR(s, *str); *str = tr; - if (**str) - (*str)++; - return s; }