fix #94: _list_append behaviour on NULL list head is now to return NULL (both for stringpair_list_append and stringlist_append)
authorKrista Grothoff <krista@pep-project.org>
Mon, 11 Jul 2016 17:04:45 +0200
changeset 8368e7dac747b49
parent 835 166e2038ea52
child 837 bdff704cd921
child 839 d2740d2c67b3
fix #94: _list_append behaviour on NULL list head is now to return NULL (both for stringpair_list_append and stringlist_append)
src/stringlist.c
src/stringlist.h
src/stringpair.c
src/stringpair.h
     1.1 --- a/src/stringlist.c	Mon Jul 11 16:17:31 2016 +0200
     1.2 +++ b/src/stringlist.c	Mon Jul 11 17:04:45 2016 +0200
     1.3 @@ -88,6 +88,8 @@
     1.4      )
     1.5  {
     1.6      assert(stringlist);
     1.7 +    if (stringlist == NULL)
     1.8 +        return NULL;
     1.9  
    1.10      if (second == NULL || second->value == NULL)
    1.11          return stringlist;
     2.1 --- a/src/stringlist.h	Mon Jul 11 16:17:31 2016 +0200
     2.2 +++ b/src/stringlist.h	Mon Jul 11 17:04:45 2016 +0200
     2.3 @@ -67,6 +67,7 @@
     2.4  //
     2.5  //  return value:
     2.6  //      pointer to last element in stringlist or NULL if out of memory
     2.7 +//      or stringpair_list is NULL
     2.8  //
     2.9  //  caveat:
    2.10  //      all values are being copied before being added to the list
     3.1 --- a/src/stringpair.c	Mon Jul 11 16:17:31 2016 +0200
     3.2 +++ b/src/stringpair.c	Mon Jul 11 17:04:45 2016 +0200
     3.3 @@ -125,23 +125,6 @@
     3.4  
     3.5      return list_curr->next;
     3.6      
     3.7 -//     if (stringpair_list == NULL)
     3.8 -//         return new_stringpair_list(value);
     3.9 -// 
    3.10 -//     if (stringpair_list->next)
    3.11 -//         return stringpair_list_add(stringpair_list->next, value);
    3.12 -// 
    3.13 -//     if (stringpair_list->value == NULL) {
    3.14 -//         assert(stringpair_list->next == NULL);
    3.15 -//         stringpair_list->value = value;
    3.16 -//         return stringpair_list;
    3.17 -//     }
    3.18 -// 
    3.19 -//     stringpair_list->next = new_stringpair_list(value);
    3.20 -//     if (stringpair_list->next == NULL)
    3.21 -//         return NULL;
    3.22 -// 
    3.23 -//     return stringpair_list->next;
    3.24  }
    3.25  
    3.26  DYNAMIC_API stringpair_list_t *stringpair_list_append(
    3.27 @@ -150,6 +133,8 @@
    3.28      )
    3.29  {
    3.30      assert(stringpair_list);
    3.31 +    if (stringpair_list == NULL)
    3.32 +        return NULL;
    3.33  
    3.34      if (second == NULL || second->value == NULL)
    3.35          return stringpair_list;
     4.1 --- a/src/stringpair.h	Mon Jul 11 16:17:31 2016 +0200
     4.2 +++ b/src/stringpair.h	Mon Jul 11 17:04:45 2016 +0200
     4.3 @@ -109,6 +109,7 @@
     4.4  //
     4.5  //  return value:
     4.6  //      pointer to last element in stringpair_list or NULL if out of memory
     4.7 +//      or stringpair_list is NULL
     4.8  //
     4.9  //  caveat:
    4.10  //      all values are being copied before being added to the list