clarify which values are okay in stringpair
authorRoker <roker@pep-project.org>
Fri, 01 Jul 2016 10:59:53 +0200
changeset 786cd0c6d03e539
parent 785 5e78006d4abf
child 787 274c303a0c5a
child 788 f75a6f866c38
clarify which values are okay in stringpair
src/stringpair.c
src/stringpair.h
     1.1 --- a/src/stringpair.c	Fri Jul 01 08:55:04 2016 +0200
     1.2 +++ b/src/stringpair.c	Fri Jul 01 10:59:53 2016 +0200
     1.3 @@ -98,6 +98,7 @@
     1.4          return stringpair_list_add(stringpair_list->next, value);
     1.5  
     1.6      if (stringpair_list->value == NULL) {
     1.7 +        assert(stringpair_list->next == NULL);
     1.8          stringpair_list->value = value;
     1.9          return stringpair_list;
    1.10      }
     2.1 --- a/src/stringpair.h	Fri Jul 01 08:55:04 2016 +0200
     2.2 +++ b/src/stringpair.h	Fri Jul 01 10:59:53 2016 +0200
     2.3 @@ -8,16 +8,16 @@
     2.4  
     2.5  
     2.6  typedef struct _stringpair_t {
     2.7 -    char * key;
     2.8 -    char * value;
     2.9 +    char * key;   // may point to "" but must not be NULL!
    2.10 +    char * value; // may point to "" but must not be NULL!
    2.11  } stringpair_t;
    2.12  
    2.13  
    2.14  // new_stringpair() - allocate new stringpair_t
    2.15  //
    2.16  //  parameters:
    2.17 -//      key (in)        utf-8 string used as key
    2.18 -//      value (in)      utf-8 string containing the value
    2.19 +//      key (in)        utf-8 string used as key; may point to "" but must not be NULL!
    2.20 +//      value (in)      utf-8 string containing the value; may point to "" but must not be NULL!
    2.21  //
    2.22  //  return value:
    2.23  //      pointer to stringpair_t or NULL on failure
    2.24 @@ -91,7 +91,7 @@
    2.25  //      pointer to last element in stringpair_list or NULL if out of memory
    2.26  //
    2.27  //  caveat:
    2.28 -//      the ownership of the value goes to the stringpair_list
    2.29 +//      the ownership of the value goes to the stringpair_list if add is successful
    2.30  
    2.31  DYNAMIC_API stringpair_list_t *stringpair_list_add(
    2.32          stringpair_list_t *stringpair_list,