From a94170d2abbe8fbbffab2f8864a7ee25186aeff1 Mon Sep 17 00:00:00 2001 From: rlar Date: Fri, 18 Oct 2013 21:29:38 +0200 Subject: [PATCH] gettok_node(), use copy_substring() --- src/misc/string.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/misc/string.c b/src/misc/string.c index be28aa0ee..1166597b5 100644 --- a/src/misc/string.c +++ b/src/misc/string.c @@ -441,7 +441,6 @@ gettok_node(char **s) { char c; char *token ; /* return token */ - SPICE_DSTRING buf ; /* allow any length string */ if (*s == NULL) return NULL; @@ -456,16 +455,18 @@ gettok_node(char **s) if (!**s) return (NULL); /* return NULL if we come to end of line */ - spice_dstring_init(&buf) ; + token = *s; while ((c = **s) != '\0' && !isspace(c) && ( **s != '(' ) && ( **s != ')' ) && ( **s != ',') ) { /* collect chars until whitespace or ( , ) */ - spice_dstring_append_char( &buf, *(*s)++ ) ; + (*s)++; } + token = copy_substring(token, *s); + /* Now iterate up to next non-whitespace char */ while (isspace(**s) || ( **s == '(' ) || @@ -474,8 +475,6 @@ gettok_node(char **s) ) (*s)++; /* iterate over whitespace and ( , ) */ - token = copy( spice_dstring_value(&buf) ) ; - spice_dstring_free(&buf) ; return ( token ) ; }