--- projects/libstatgrab/src/libstatgrab/tools.c 2004/04/05 15:40:15 1.41 +++ projects/libstatgrab/src/libstatgrab/tools.c 2004/04/05 18:10:11 1.42 @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA * - * $Id: tools.c,v 1.41 2004/04/05 15:40:15 ats Exp $ + * $Id: tools.c,v 1.42 2004/04/05 18:10:11 ats Exp $ */ #ifdef HAVE_CONFIG_H @@ -403,17 +403,24 @@ size_t sg_strlcat(char *dst, const char *src, size_t s return(dlen + (s - src)); /* count does not include NUL */ } -char *sg_update_string(char **dest, const char *src) { +int sg_update_string(char **dest, const char *src) { char *new; + if (src == NULL) { + /* We're being told to set it to NULL. */ + free(*dest); + *dest = NULL; + return 0; + } + new = realloc(*dest, strlen(src) + 1); if (new == NULL) { - return NULL; + return -1; } strcpy(new, src); *dest = new; - return new; + return 0; } long long sg_get_ll_match(char *line, regmatch_t *match){