copying release_value with bloblist_add
authorVolker Birk <vb@pep.foundation>
Mon, 15 Jan 2018 18:48:54 +0100
changeset 23837c30555558b6
parent 2382 3cd19d2efe03
child 2384 573121b93c51
copying release_value with bloblist_add
src/bloblist.c
src/bloblist.h
     1.1 --- a/src/bloblist.c	Mon Jan 15 18:13:53 2018 +0100
     1.2 +++ b/src/bloblist.c	Mon Jan 15 18:48:54 2018 +0100
     1.3 @@ -135,6 +135,7 @@
     1.4          return new_bloblist(blob, size, mime_type, filename);
     1.5  
     1.6      if (bloblist->value == NULL) { // empty list
     1.7 +        assert(bloblist->next);
     1.8          if (bloblist->next != NULL)
     1.9              return NULL; // invalid list
    1.10              
    1.11 @@ -147,11 +148,13 @@
    1.12      }
    1.13  
    1.14      bloblist_t* list_curr = bloblist;
    1.15 +    void (*release_value)(char *) = list_curr->release_value;
    1.16  
    1.17      while (list_curr->next)
    1.18          list_curr = list_curr->next;
    1.19  
    1.20      list_curr->next = new_bloblist(blob, size, mime_type, filename);
    1.21 +    list_curr->release_value = release_value;
    1.22  
    1.23      assert(list_curr->next);
    1.24      if (list_curr->next == NULL)
     2.1 --- a/src/bloblist.h	Mon Jan 15 18:13:53 2018 +0100
     2.2 +++ b/src/bloblist.h	Mon Jan 15 18:48:54 2018 +0100
     2.3 @@ -46,6 +46,10 @@
     2.4  //  caveat:
     2.5  //      the ownership of the blob goes to the bloblist; mime_type and filename
     2.6  //      are being copied, the originals remain in the ownership of the caller
     2.7 +//
     2.8 +//      if blob is on a different heap then after the call release_value has to
     2.9 +//      be set by the adapter; this is relevant on operating systems with
    2.10 +//      multiple heaps like Microsoft Windows
    2.11  
    2.12  DYNAMIC_API bloblist_t *new_bloblist(char *blob, size_t size, const char *mime_type,
    2.13          const char *filename);
    2.14 @@ -72,6 +76,7 @@
    2.15  
    2.16  DYNAMIC_API bloblist_t *bloblist_dup(const bloblist_t *src);
    2.17  
    2.18 +
    2.19  // bloblist_add() - add reference to a blob to bloblist
    2.20  //
    2.21  //  parameters:
    2.22 @@ -90,6 +95,9 @@
    2.23  //      are being copied, the originals remain in the ownership of the caller.
    2.24  //      bloblist input parameter equal to NULL or with value == NULL is a valid
    2.25  //      empty input list.
    2.26 +//
    2.27 +//      If there is release_value set in bloblist it is copied to the added
    2.28 +//      leaf
    2.29  
    2.30  DYNAMIC_API bloblist_t *bloblist_add(bloblist_t *bloblist, char *blob, size_t size,
    2.31          const char *mime_type, const char *filename);
    2.32 @@ -105,6 +113,7 @@
    2.33  
    2.34  DYNAMIC_API int bloblist_length(const bloblist_t *bloblist);
    2.35  
    2.36 +
    2.37  // set_blob_content_disposition() - set blob content disposition and parameters
    2.38  //                                  when necessary
    2.39  //
    2.40 @@ -113,9 +122,7 @@
    2.41  //      disposition (in)        disposition type (see enum)
    2.42  
    2.43  DYNAMIC_API void set_blob_disposition(bloblist_t* blob, 
    2.44 -                                              content_disposition_type disposition);
    2.45 -
    2.46 -
    2.47 +        content_disposition_type disposition);
    2.48  
    2.49  
    2.50  #ifdef __cplusplus