gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [libmicrohttpd] 01/02: add MHD_create_response_from_buffer_


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] 01/02: add MHD_create_response_from_buffer_with_free_callback
Date: Thu, 08 Nov 2018 14:53:49 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository libmicrohttpd.

commit 10bdf39505cf525b95886c140b3c2e82e7427d29
Author: Christian Grothoff <address@hidden>
AuthorDate: Thu Nov 8 14:53:19 2018 +0100

    add MHD_create_response_from_buffer_with_free_callback
---
 doc/libmicrohttpd.texi    | 18 ++++++++++++++++++
 src/include/microhttpd.h  | 18 ++++++++++++++++++
 src/microhttpd/response.c | 28 ++++++++++++++++++++++++++++
 3 files changed, 64 insertions(+)

diff --git a/doc/libmicrohttpd.texi b/doc/libmicrohttpd.texi
index 2ecb64e6..d87dac76 100644
--- a/doc/libmicrohttpd.texi
+++ b/doc/libmicrohttpd.texi
@@ -2020,6 +2020,24 @@ Return @code{NULL} on error (i.e. invalid arguments, out 
of memory).
 @end deftypefun
 
 
address@hidden {struct MHD_Response *} 
MHD_create_response_from_buffer_with_free_callback (size_t size, void *data,  
MHD_ContentReaderFreeCallback crfc)
+Create a response object.  The buffer at the end must be free'd
+by calling the @var{crfc} function.
+
address@hidden @var
address@hidden size
+size of the data portion of the response;
+
address@hidden buffer
+the data itself;
+
address@hidden crfc
+function to call at the end to free memory allocated at @var{buffer}.
address@hidden table
+
+Return @code{NULL} on error (i.e. invalid arguments, out of memory).
address@hidden deftypefun
+
 @deftypefun {struct MHD_Response *} MHD_create_response_from_data (size_t 
size, void *data, int must_free, int must_copy)
 Create a response object.  The response object can be extended with
 header information and then it can be used any number of times.
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index 70ecd6e9..f8ec0122 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -2763,6 +2763,24 @@ MHD_create_response_from_buffer (size_t size,
                                 enum MHD_ResponseMemoryMode mode);
 
 
+
+
+/**
+ * Create a response object.  The response object can be extended with
+ * header information and then be used any number of times.
+ *
+ * @param size size of the data portion of the response
+ * @param buffer size bytes containing the response's data portion
+ * @param crfc function to call to free the @a buffer
+ * @return NULL on error (i.e. invalid arguments, out of memory)
+ * @ingroup response
+ */
+_MHD_EXTERN struct MHD_Response *
+MHD_create_response_from_buffer_with_free_callback (size_t size,
+                                                   void *buffer,
+                                                   
MHD_ContentReaderFreeCallback crfc);
+
+
 /**
  * Create a response object.  The response object can be extended with
  * header information and then be used any number of times.
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index d7835c20..08b7805d 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -701,6 +701,34 @@ MHD_create_response_from_buffer (size_t size,
 }
 
 
+/**
+ * Create a response object.  The response object can be extended with
+ * header information and then be used any number of times.
+ *
+ * @param size size of the data portion of the response
+ * @param buffer size bytes containing the response's data portion
+ * @param crfc function to call to free the @a buffer
+ * @return NULL on error (i.e. invalid arguments, out of memory)
+ * @ingroup response
+ */
+_MHD_EXTERN struct MHD_Response *
+MHD_create_response_from_buffer_with_free_callback (size_t size,
+                                                   void *buffer,
+                                                   
MHD_ContentReaderFreeCallback crfc)
+{
+  struct MHD_Response *r;
+
+  r = MHD_create_response_from_data (size,
+                                    buffer,
+                                    GNUNET_YES,
+                                    GNUNET_NO);
+  if (NULL == r)
+    return r;
+  r->crfc = crfc;
+  return r;
+}
+
+
 #ifdef UPGRADE_SUPPORT
 /**
  * This connection-specific callback is provided by MHD to

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]