diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-07-18 06:46:18 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-07-18 06:46:18 +0000 |
commit | 0216a0f9b312a7dbfd4b6d0919fcb7c3d9f93c71 (patch) | |
tree | bb164592ac83a9250f2027762e7e7c9ce3eb74e9 | |
parent | 0601a3bf713a1f196927f7a381cce56ebbf8aa04 (diff) | |
download | libmicrohttpd-0216a0f9b312a7dbfd4b6d0919fcb7c3d9f93c71.tar.gz libmicrohttpd-0216a0f9b312a7dbfd4b6d0919fcb7c3d9f93c71.zip |
avoid asprintf
-rw-r--r-- | src/examples/post_example.c | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/src/examples/post_example.c b/src/examples/post_example.c index 6bb81a0b..69091dc2 100644 --- a/src/examples/post_example.c +++ b/src/examples/post_example.c | |||
@@ -22,10 +22,6 @@ | |||
22 | * @author Christian Grothoff | 22 | * @author Christian Grothoff |
23 | */ | 23 | */ |
24 | 24 | ||
25 | /* needed for asprintf */ | ||
26 | #define _GNU_SOURCE | ||
27 | |||
28 | |||
29 | #include <stdlib.h> | 25 | #include <stdlib.h> |
30 | #include <string.h> | 26 | #include <string.h> |
31 | #include <stdio.h> | 27 | #include <stdio.h> |
@@ -319,13 +315,11 @@ fill_v1_form (const void *cls, | |||
319 | char *reply; | 315 | char *reply; |
320 | struct MHD_Response *response; | 316 | struct MHD_Response *response; |
321 | 317 | ||
322 | if (-1 == asprintf (&reply, | 318 | reply = malloc (strlen (form) + strlen (session->value_1) + 1); |
323 | form, | 319 | snprintf (reply, |
324 | session->value_1)) | 320 | strlen (form) + strlen (session->value_1) + 1, |
325 | { | 321 | form, |
326 | /* oops */ | 322 | session->value_1); |
327 | return MHD_NO; | ||
328 | } | ||
329 | /* return static form */ | 323 | /* return static form */ |
330 | response = MHD_create_response_from_buffer (strlen (reply), | 324 | response = MHD_create_response_from_buffer (strlen (reply), |
331 | (void *) reply, | 325 | (void *) reply, |
@@ -361,14 +355,11 @@ fill_v1_v2_form (const void *cls, | |||
361 | char *reply; | 355 | char *reply; |
362 | struct MHD_Response *response; | 356 | struct MHD_Response *response; |
363 | 357 | ||
364 | if (-1 == asprintf (&reply, | 358 | reply = malloc (strlen (form) + strlen (session->value_1) + strlen (session->value_2) + 1); |
365 | form, | 359 | snprintf (reply, |
366 | session->value_1, | 360 | strlen (form) + strlen (session->value_1) + strlen (session->value_2) + 1, |
367 | session->value_2)) | 361 | form, |
368 | { | 362 | session->value_1); |
369 | /* oops */ | ||
370 | return MHD_NO; | ||
371 | } | ||
372 | /* return static form */ | 363 | /* return static form */ |
373 | response = MHD_create_response_from_buffer (strlen (reply), | 364 | response = MHD_create_response_from_buffer (strlen (reply), |
374 | (void *) reply, | 365 | (void *) reply, |