fix #99: stringlist_free now iterative
authorKrista Grothoff <krista@pep-project.org>
Mon, 11 Jul 2016 09:21:23 +0200
changeset 828ea7e5920eda3
parent 827 37f1b63ecf97
child 829 7bb16947031a
fix #99: stringlist_free now iterative
src/stringlist.c
     1.1 --- a/src/stringlist.c	Mon Jul 11 09:08:34 2016 +0200
     1.2 +++ b/src/stringlist.c	Mon Jul 11 09:21:23 2016 +0200
     1.3 @@ -148,10 +148,16 @@
     1.4  
     1.5  DYNAMIC_API void free_stringlist(stringlist_t *stringlist)
     1.6  {
     1.7 -    if (stringlist) {
     1.8 -        free_stringlist(stringlist->next);
     1.9 -        free(stringlist->value);
    1.10 -        free(stringlist);
    1.11 +    stringlist_t *curr;
    1.12 +    stringlist_t *next;
    1.13 +    
    1.14 +    curr = stringlist;
    1.15 +    
    1.16 +    while (curr) {
    1.17 +        next = curr->next;
    1.18 +        free(curr->value);
    1.19 +        free(curr);
    1.20 +        curr = next;
    1.21      }
    1.22  }
    1.23