aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-05-20 13:09:59 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-05-20 13:12:21 +0300
commit4a4d659bac5040c7f7538e28535b4baaa1529ba8 (patch)
tree723229c02ca0df6601d59f3dd3b91901b0acaf04
parent664d8ca99f681d6f222ec754f3f1d2943b78df7c (diff)
downloadlibmicrohttpd-4a4d659bac5040c7f7538e28535b4baaa1529ba8.tar.gz
libmicrohttpd-4a4d659bac5040c7f7538e28535b4baaa1529ba8.zip
connection_alloc_memory_(): made function non-static
-rw-r--r--src/microhttpd/connection.c18
-rw-r--r--src/microhttpd/connection.h14
2 files changed, 23 insertions, 9 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index a260933c..f178f44e 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -242,9 +242,9 @@ str_conn_error_ (ssize_t mhd_err_code)
242 * @return pointer to allocated memory region in the pool or 242 * @return pointer to allocated memory region in the pool or
243 * NULL if no memory is available 243 * NULL if no memory is available
244 */ 244 */
245static void * 245void *
246connection_alloc_memory (struct MHD_Connection *connection, 246MHD_connection_alloc_memory_ (struct MHD_Connection *connection,
247 size_t size) 247 size_t size)
248{ 248{
249 struct MHD_Connection *const c = connection; /* a short alias */ 249 struct MHD_Connection *const c = connection; /* a short alias */
250 struct MemoryPool *const pool = c->pool; /* a short alias */ 250 struct MemoryPool *const pool = c->pool; /* a short alias */
@@ -482,8 +482,8 @@ MHD_set_connection_value_n_nocheck_ (struct MHD_Connection *connection,
482{ 482{
483 struct MHD_HTTP_Req_Header *pos; 483 struct MHD_HTTP_Req_Header *pos;
484 484
485 pos = connection_alloc_memory (connection, 485 pos = MHD_connection_alloc_memory_ (connection,
486 sizeof (struct MHD_HTTP_Res_Header)); 486 sizeof (struct MHD_HTTP_Res_Header));
487 if (NULL == pos) 487 if (NULL == pos)
488 return MHD_NO; 488 return MHD_NO;
489 pos->header = key; 489 pos->header = key;
@@ -1033,8 +1033,8 @@ try_ready_normal_body (struct MHD_Connection *connection)
1033 if (NULL != connection->resp_iov.iov) 1033 if (NULL != connection->resp_iov.iov)
1034 return MHD_YES; 1034 return MHD_YES;
1035 copy_size = response->data_iovcnt * sizeof(MHD_iovec_); 1035 copy_size = response->data_iovcnt * sizeof(MHD_iovec_);
1036 connection->resp_iov.iov = connection_alloc_memory (connection, 1036 connection->resp_iov.iov = MHD_connection_alloc_memory_ (connection,
1037 copy_size); 1037 copy_size);
1038 if (NULL == connection->resp_iov.iov) 1038 if (NULL == connection->resp_iov.iov)
1039 { 1039 {
1040 MHD_mutex_unlock_chk_ (&response->mutex); 1040 MHD_mutex_unlock_chk_ (&response->mutex);
@@ -3103,8 +3103,8 @@ parse_cookie_header (struct MHD_Connection *connection)
3103 if (0 == hdr_len) 3103 if (0 == hdr_len)
3104 return MHD_PARSE_COOKIE_OK; 3104 return MHD_PARSE_COOKIE_OK;
3105 3105
3106 cpy = connection_alloc_memory (connection, 3106 cpy = MHD_connection_alloc_memory_ (connection,
3107 hdr_len + 1); 3107 hdr_len + 1);
3108 if (NULL == cpy) 3108 if (NULL == cpy)
3109 return MHD_PARSE_COOKIE_NO_MEMORY; 3109 return MHD_PARSE_COOKIE_NO_MEMORY;
3110 3110
diff --git a/src/microhttpd/connection.h b/src/microhttpd/connection.h
index 9f1a0ffb..693e26fc 100644
--- a/src/microhttpd/connection.h
+++ b/src/microhttpd/connection.h
@@ -190,4 +190,18 @@ MHD_connection_epoll_update_ (struct MHD_Connection *connection);
190void 190void
191MHD_update_last_activity_ (struct MHD_Connection *connection); 191MHD_update_last_activity_ (struct MHD_Connection *connection);
192 192
193
194/**
195 * Allocate memory from connection's memory pool.
196 * If memory pool doesn't have enough free memory but read or write buffer
197 * have some unused memory, the size of the buffer will be reduced as needed.
198 * @param connection the connection to use
199 * @param size the size of allocated memory area
200 * @return pointer to allocated memory region in the pool or
201 * NULL if no memory is available
202 */
203void *
204MHD_connection_alloc_memory_ (struct MHD_Connection *connection,
205 size_t size);
206
193#endif 207#endif