commit dd2123098702285101d944d79f8bc668b1a2622c
parent 6e7e5e26e465b42a90267f3d3fb868b1e20051bb
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Mon, 16 Aug 2021 11:25:27 +0300
test_get_chunked: do not allocate buffer for cls when not needed
Diffstat:
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/testcurl/test_get_chunked.c b/src/testcurl/test_get_chunked.c
@@ -180,7 +180,6 @@ ahc_echo (void *cls,
static int aptr;
const char *me = cls;
struct MHD_Response *response;
- struct MHD_Response **responseptr;
enum MHD_Result ret;
(void) url;
@@ -196,17 +195,20 @@ ahc_echo (void *cls,
*ptr = &aptr;
return MHD_YES;
}
- responseptr = malloc (sizeof (struct MHD_Response *));
- if (NULL == responseptr)
- _exit (99);
if (! resp_string)
{
+ struct MHD_Response **responseptr;
+ responseptr = malloc (sizeof (struct MHD_Response *));
+ if (NULL == responseptr)
+ _exit (99);
+
response = MHD_create_response_from_callback (resp_sized ?
RESP_SIZE : MHD_SIZE_UNKNOWN,
1024,
&crc,
responseptr,
&crcf);
+ *responseptr = response;
}
else
{
@@ -246,7 +248,6 @@ ahc_echo (void *cls,
abort ();
}
- *responseptr = response;
ret = MHD_queue_response (connection,
MHD_HTTP_OK,
response);