fix #23: identity_list_dup now iterative
authorKrista Grothoff <krista@pep-project.org>
Sun, 17 Jul 2016 10:57:58 +0200
changeset 892f1155b6285aa
parent 891 e4c80fda31af
child 893 1414001528b3
fix #23: identity_list_dup now iterative
src/identity_list.c
     1.1 --- a/src/identity_list.c	Sun Jul 17 10:12:33 2016 +0200
     1.2 +++ b/src/identity_list.c	Sun Jul 17 10:57:58 2016 +0200
     1.3 @@ -32,15 +32,37 @@
     1.4      if (id_list == NULL)
     1.5          return NULL;
     1.6  
     1.7 -    if (src->next) {
     1.8 -        id_list->next = identity_list_dup(src->next);
     1.9 -        if (id_list->next == NULL) {
    1.10 -            free_identity_list(id_list);
    1.11 -            return NULL;
    1.12 -        }
    1.13 +    identity_list* src_curr = id_list->next;
    1.14 +    identity_list** dst_curr_ptr = &id_list->next;
    1.15 +    
    1.16 +    while (src_curr) {
    1.17 +        _ident = identity_dup(src_curr->ident);
    1.18 +        *dst_curr_ptr = new_identity_list(_ident);
    1.19 +        src_curr = src_curr->next;
    1.20 +        dst_curr_ptr = &((*dst_curr_ptr)->next);
    1.21      }
    1.22 -
    1.23 +    
    1.24      return id_list;
    1.25 +    
    1.26 +    
    1.27 +//         assert(src);
    1.28 +//     if (src == NULL)
    1.29 +//         return NULL;
    1.30 +// 
    1.31 +//     stringlist_t *dst = new_stringlist(src->value);
    1.32 +//     if (dst == NULL)
    1.33 +//         return NULL;
    1.34 +// 
    1.35 +//     stringlist_t* src_curr = src->next;
    1.36 +//     stringlist_t** dst_curr_ptr = &dst->next;
    1.37 +//     
    1.38 +//     while (src_curr) {
    1.39 +//         *dst_curr_ptr = new_stringlist(src_curr->value);
    1.40 +//         src_curr = src_curr->next;
    1.41 +//         dst_curr_ptr = &((*dst_curr_ptr)->next);
    1.42 +//     }
    1.43 +// 
    1.44 +//     return dst;
    1.45  }
    1.46  
    1.47  DYNAMIC_API void free_identity_list(identity_list *id_list)