Fixed ownership problem with bloblist value
authorKrista Grothoff <krista@pep-project.org>
Thu, 24 Nov 2016 13:51:15 +0100
changeset 1440dabd893967de
parent 1438 a52c24619e1c
child 1442 5703f6e67269
child 1443 2a12b9227fb1
Fixed ownership problem with bloblist value
src/bloblist.c
     1.1 --- a/src/bloblist.c	Thu Nov 24 10:26:27 2016 +0100
     1.2 +++ b/src/bloblist.c	Thu Nov 24 13:51:15 2016 +0100
     1.3 @@ -43,9 +43,9 @@
     1.4  {
     1.5      bloblist_t *curr;
     1.6      bloblist_t *next;
     1.7 -    
     1.8 +
     1.9      curr = bloblist;
    1.10 -    
    1.11 +
    1.12      while (curr) {
    1.13          next = curr->next;
    1.14          free(curr->value);
    1.15 @@ -79,7 +79,7 @@
    1.16  
    1.17      bloblist_t* src_curr = src->next;
    1.18      bloblist_t** dst_curr_ptr = &bloblist->next;
    1.19 -    
    1.20 +
    1.21      // list
    1.22      while (src_curr) {
    1.23          blob2 = malloc(src_curr->size);
    1.24 @@ -92,11 +92,11 @@
    1.25          *dst_curr_ptr = new_bloblist(blob2, src_curr->size, src_curr->mime_type, src_curr->filename);
    1.26          if (*dst_curr_ptr == NULL)
    1.27              goto enomem;
    1.28 -        
    1.29 +
    1.30          src_curr = src_curr->next;
    1.31          dst_curr_ptr = &((*dst_curr_ptr)->next);
    1.32      }
    1.33 -        
    1.34 +
    1.35      return bloblist;
    1.36  
    1.37  enomem:
    1.38 @@ -111,14 +111,14 @@
    1.39      assert(blob);
    1.40      if (blob == NULL)
    1.41          return NULL;
    1.42 -    
    1.43 +
    1.44      if (bloblist == NULL)
    1.45          return new_bloblist(blob, size, mime_type, filename);
    1.46  
    1.47      if (bloblist->value == NULL) { // empty list
    1.48          if (bloblist->next != NULL)
    1.49              return NULL; // invalid list
    1.50 -            
    1.51 +
    1.52          if (mime_type) {
    1.53              bloblist->mime_type = strdup(mime_type);
    1.54              if (bloblist->mime_type == NULL) {
    1.55 @@ -142,18 +142,18 @@
    1.56      }
    1.57  
    1.58      bloblist_t* list_curr = bloblist;
    1.59 -    
    1.60 +
    1.61      while (list_curr->next)
    1.62          list_curr = list_curr->next;
    1.63 -    
    1.64 +
    1.65      list_curr->next = new_bloblist(blob, size, mime_type, filename);
    1.66 -    
    1.67 +
    1.68      assert(list_curr->next);
    1.69      if (list_curr->next == NULL)
    1.70          return NULL;
    1.71 -   
    1.72 +
    1.73      return list_curr->next;
    1.74 -    
    1.75 +
    1.76  }
    1.77  
    1.78  DYNAMIC_API int bloblist_length(const bloblist_t *bloblist)
    1.79 @@ -169,13 +169,12 @@
    1.80  bloblist_t* consume_bloblist_head(bloblist_t *bloblist_head) {
    1.81      if (!bloblist_head)
    1.82          return NULL;
    1.83 -    
    1.84 +
    1.85      bloblist_t* next = bloblist_head->next;
    1.86 -        
    1.87 -    free(bloblist_head->value);
    1.88 +
    1.89      free(bloblist_head->mime_type);
    1.90      free(bloblist_head->filename);
    1.91      free(bloblist_head);
    1.92 -    
    1.93 +
    1.94      return next;
    1.95  }