diff options
Diffstat (limited to 'src/lib/response_from_buffer.c')
-rw-r--r-- | src/lib/response_from_buffer.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/src/lib/response_from_buffer.c b/src/lib/response_from_buffer.c index a53537b0..a65a0298 100644 --- a/src/lib/response_from_buffer.c +++ b/src/lib/response_from_buffer.c | |||
@@ -39,44 +39,44 @@ | |||
39 | */ | 39 | */ |
40 | struct MHD_Response * | 40 | struct MHD_Response * |
41 | MHD_response_from_buffer (enum MHD_HTTP_StatusCode sc, | 41 | MHD_response_from_buffer (enum MHD_HTTP_StatusCode sc, |
42 | size_t size, | 42 | size_t size, |
43 | void *buffer, | 43 | void *buffer, |
44 | enum MHD_ResponseMemoryMode mode) | 44 | enum MHD_ResponseMemoryMode mode) |
45 | { | 45 | { |
46 | struct MHD_Response *response; | 46 | struct MHD_Response *response; |
47 | void *tmp; | 47 | void *tmp; |
48 | 48 | ||
49 | mhd_assert ( (NULL != buffer) || | 49 | mhd_assert ( (NULL != buffer) || |
50 | (0 == size) ); | 50 | (0 == size) ); |
51 | if (NULL == | 51 | if (NULL == |
52 | (response = MHD_calloc_ (1, | 52 | (response = MHD_calloc_ (1, |
53 | sizeof (struct MHD_Response)))) | 53 | sizeof (struct MHD_Response)))) |
54 | return NULL; | 54 | return NULL; |
55 | response->fd = -1; | 55 | response->fd = -1; |
56 | if (! MHD_mutex_init_ (&response->mutex)) | 56 | if (! MHD_mutex_init_ (&response->mutex)) |
57 | { | 57 | { |
58 | free (response); | 58 | free (response); |
59 | return NULL; | 59 | return NULL; |
60 | } | 60 | } |
61 | if ( (MHD_RESPMEM_MUST_COPY == mode) && | 61 | if ( (MHD_RESPMEM_MUST_COPY == mode) && |
62 | (size > 0) ) | 62 | (size > 0) ) |
63 | { | ||
64 | if (NULL == (tmp = malloc (size))) | ||
63 | { | 65 | { |
64 | if (NULL == (tmp = malloc (size))) | 66 | MHD_mutex_destroy_chk_ (&response->mutex); |
65 | { | 67 | free (response); |
66 | MHD_mutex_destroy_chk_ (&response->mutex); | 68 | return NULL; |
67 | free (response); | ||
68 | return NULL; | ||
69 | } | ||
70 | memcpy (tmp, | ||
71 | buffer, | ||
72 | size); | ||
73 | buffer = tmp; | ||
74 | } | 69 | } |
70 | memcpy (tmp, | ||
71 | buffer, | ||
72 | size); | ||
73 | buffer = tmp; | ||
74 | } | ||
75 | if (MHD_RESPMEM_PERSISTENT != mode) | 75 | if (MHD_RESPMEM_PERSISTENT != mode) |
76 | { | 76 | { |
77 | response->crfc = &free; | 77 | response->crfc = &free; |
78 | response->crc_cls = buffer; | 78 | response->crc_cls = buffer; |
79 | } | 79 | } |
80 | response->status_code = sc; | 80 | response->status_code = sc; |
81 | response->reference_count = 1; | 81 | response->reference_count = 1; |
82 | response->total_size = size; | 82 | response->total_size = size; |