aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/connection.c
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2023-04-05 16:48:35 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2023-04-05 19:44:49 +0300
commitedf692a61627394c26132e203857afc5237495c3 (patch)
tree0d06ed9cad5859d2051553da6f492a8e15fc50f9 /src/microhttpd/connection.c
parent95ad2a9a480435e86dfa1bbd7a6798150320d3bd (diff)
downloadlibmicrohttpd-edf692a61627394c26132e203857afc5237495c3.tar.gz
libmicrohttpd-edf692a61627394c26132e203857afc5237495c3.zip
Implemented and used new function MHD_pool_deallocate()
The new function has special handling for user-poison mode.
Diffstat (limited to 'src/microhttpd/connection.c')
-rw-r--r--src/microhttpd/connection.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index f378334c..82b127b9 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -1597,11 +1597,20 @@ connection_shrink_read_buffer (struct MHD_Connection *connection)
1597 } 1597 }
1598 1598
1599 mhd_assert (c->read_buffer_offset <= c->read_buffer_size); 1599 mhd_assert (c->read_buffer_offset <= c->read_buffer_size);
1600 new_buf = MHD_pool_reallocate (c->pool, c->read_buffer, c->read_buffer_size, 1600 if (0 == c->read_buffer_offset)
1601 c->read_buffer_offset); 1601 {
1602 mhd_assert (c->read_buffer == new_buf); 1602 MHD_pool_deallocate (c->pool, c->read_buffer, c->read_buffer_size);
1603 c->read_buffer = new_buf; 1603 c->read_buffer = NULL;
1604 c->read_buffer_size = c->read_buffer_offset; 1604 c->read_buffer_size = 0;
1605 }
1606 else
1607 {
1608 new_buf = MHD_pool_reallocate (c->pool, c->read_buffer, c->read_buffer_size,
1609 c->read_buffer_offset);
1610 mhd_assert (c->read_buffer == new_buf);
1611 c->read_buffer = new_buf;
1612 c->read_buffer_size = c->read_buffer_offset;
1613 }
1605} 1614}
1606 1615
1607 1616
@@ -2424,10 +2433,10 @@ transmit_error_response_len (struct MHD_Connection *connection,
2424 { 2433 {
2425 /* Read buffer is not needed anymore, discard it 2434 /* Read buffer is not needed anymore, discard it
2426 * to free some space for error response. */ 2435 * to free some space for error response. */
2427 connection->read_buffer = MHD_pool_reallocate (connection->pool, 2436 MHD_pool_deallocate (connection->pool,
2428 connection->read_buffer, 2437 connection->read_buffer,
2429 connection->read_buffer_size, 2438 connection->read_buffer_size);
2430 0); 2439 connection->read_buffer = NULL;
2431 connection->read_buffer_size = 0; 2440 connection->read_buffer_size = 0;
2432 connection->read_buffer_offset = 0; 2441 connection->read_buffer_offset = 0;
2433 } 2442 }