mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-10-08 23:43:54 +03:00
Replaced MHD_RESPMEM_MUST_FREE with more portable solution in examples
This commit is contained in:
7 files changed
+50
-34
No files matched your search
+4
-3
@@ -383,9 +383,10 @@ update_directory (void)
|
||||
"%s",
|
||||
INDEX_PAGE_FOOTER);
|
||||
initial_allocation = rdc.buf_len; /* remember for next time */
|
||||
response = MHD_create_response_from_buffer (rdc.off,
|
||||
rdc.buf,
|
||||
MHD_RESPMEM_MUST_FREE);
|
||||
response =
|
||||
MHD_create_response_from_buffer_with_free_callback (rdc.off,
|
||||
rdc.buf,
|
||||
&free);
|
||||
mark_as_html (response);
|
||||
#if FORCE_CLOSE
|
||||
(void) MHD_add_response_header (response,
|
||||
|
||||
@@ -385,9 +385,10 @@ update_directory (void)
|
||||
"%s",
|
||||
INDEX_PAGE_FOOTER);
|
||||
initial_allocation = rdc.buf_len; /* remember for next time */
|
||||
response = MHD_create_response_from_buffer (rdc.off,
|
||||
rdc.buf,
|
||||
MHD_RESPMEM_MUST_FREE);
|
||||
response =
|
||||
MHD_create_response_from_buffer_with_free_callback (rdc.off,
|
||||
rdc.buf,
|
||||
&free);
|
||||
mark_as_html (response);
|
||||
#if FORCE_CLOSE
|
||||
(void) MHD_add_response_header (response,
|
||||
|
||||
@@ -130,9 +130,11 @@ ahc_echo (void *cls,
|
||||
can_compress (connection))
|
||||
comp = body_compress ((void **) &body_str,
|
||||
&body_len);
|
||||
response = MHD_create_response_from_buffer (body_len,
|
||||
body_str,
|
||||
MHD_RESPMEM_MUST_FREE);
|
||||
response =
|
||||
MHD_create_response_from_buffer_with_free_callback (body_len,
|
||||
body_str,
|
||||
&free);
|
||||
|
||||
if (NULL == response)
|
||||
{
|
||||
free (body_str);
|
||||
|
||||
@@ -332,9 +332,10 @@ fill_v1_form (const void *cls,
|
||||
MAIN_PAGE,
|
||||
session->value_1);
|
||||
/* return static form */
|
||||
response = MHD_create_response_from_buffer (slen,
|
||||
(void *) reply,
|
||||
MHD_RESPMEM_MUST_FREE);
|
||||
response =
|
||||
MHD_create_response_from_buffer_with_free_callback (slen,
|
||||
(void *) reply,
|
||||
&free);
|
||||
if (NULL == response)
|
||||
{
|
||||
free (reply);
|
||||
@@ -383,9 +384,10 @@ fill_v1_v2_form (const void *cls,
|
||||
session->value_1,
|
||||
session->value_2);
|
||||
/* return static form */
|
||||
response = MHD_create_response_from_buffer (slen,
|
||||
(void *) reply,
|
||||
MHD_RESPMEM_MUST_FREE);
|
||||
response =
|
||||
MHD_create_response_from_buffer_with_free_callback (slen,
|
||||
(void *) reply,
|
||||
&free);
|
||||
if (NULL == response)
|
||||
{
|
||||
free (reply);
|
||||
|
||||
@@ -72,8 +72,10 @@ ahc_echo (void *cls,
|
||||
free (me);
|
||||
return MHD_NO; /* Error forming the response body */
|
||||
}
|
||||
response = MHD_create_response_from_buffer (resp_len, me,
|
||||
MHD_RESPMEM_MUST_FREE);
|
||||
response =
|
||||
MHD_create_response_from_buffer_with_free_callback (resp_len,
|
||||
(void *) me,
|
||||
&free);
|
||||
if (response == NULL)
|
||||
{
|
||||
free (me);
|
||||
|
||||
@@ -3624,10 +3624,12 @@ enum MHD_ResponseMemoryMode
|
||||
* Buffer is heap-allocated with `malloc()` (or equivalent) and
|
||||
* should be freed by MHD after processing the response has
|
||||
* concluded (response reference counter reaches zero).
|
||||
* @warning Make sure that your application and MHD are using the same
|
||||
* C-runtime library (especially important for W32). if in doubt,
|
||||
* use function MHD_create_response_from_buffer_with_free_callback()
|
||||
* with '&free' as crfc parameter.
|
||||
* The more portable way to automatically free the buffer is function
|
||||
* MHD_create_response_from_buffer_with_free_callback() with '&free' as
|
||||
* crfc parameter as it does not require to use the same runtime library.
|
||||
* @warning It is critical to make sure that the same C-runtime library
|
||||
* is used by both application and MHD (especially
|
||||
* important for W32).
|
||||
* @ingroup response
|
||||
*/
|
||||
MHD_RESPMEM_MUST_FREE,
|
||||
|
||||
Reference in new issue
Block a user