diff options
Diffstat (limited to 'doc/examples/sessions.c')
-rw-r--r-- | doc/examples/sessions.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/doc/examples/sessions.c b/doc/examples/sessions.c index 9b36c485..121cf2e0 100644 --- a/doc/examples/sessions.c +++ b/doc/examples/sessions.c | |||
@@ -347,19 +347,22 @@ fill_v1_form (const void *cls, | |||
347 | enum MHD_Result ret; | 347 | enum MHD_Result ret; |
348 | char *reply; | 348 | char *reply; |
349 | struct MHD_Response *response; | 349 | struct MHD_Response *response; |
350 | int reply_len; | ||
350 | (void) cls; /* Unused */ | 351 | (void) cls; /* Unused */ |
351 | 352 | ||
352 | if (-1 == MHD_asprintf (&reply, | 353 | reply_len = MHD_asprintf (&reply, |
353 | MAIN_PAGE, | 354 | MAIN_PAGE, |
354 | session->value_1)) | 355 | session->value_1); |
356 | if (0 > reply_len) | ||
355 | { | 357 | { |
356 | /* oops */ | 358 | /* oops */ |
357 | return MHD_NO; | 359 | return MHD_NO; |
358 | } | 360 | } |
359 | /* return static form */ | 361 | /* return static form */ |
360 | response = MHD_create_response_from_buffer (strlen (reply), | 362 | response = |
361 | (void *) reply, | 363 | MHD_create_response_from_buffer_with_free_callback ((size_t) reply_len, |
362 | MHD_RESPMEM_MUST_FREE); | 364 | (void *) reply, |
365 | &free); | ||
363 | add_session_cookie (session, response); | 366 | add_session_cookie (session, response); |
364 | MHD_add_response_header (response, | 367 | MHD_add_response_header (response, |
365 | MHD_HTTP_HEADER_CONTENT_ENCODING, | 368 | MHD_HTTP_HEADER_CONTENT_ENCODING, |
@@ -389,20 +392,23 @@ fill_v1_v2_form (const void *cls, | |||
389 | enum MHD_Result ret; | 392 | enum MHD_Result ret; |
390 | char *reply; | 393 | char *reply; |
391 | struct MHD_Response *response; | 394 | struct MHD_Response *response; |
395 | int reply_len; | ||
392 | (void) cls; /* Unused */ | 396 | (void) cls; /* Unused */ |
393 | 397 | ||
394 | if (-1 == MHD_asprintf (&reply, | 398 | reply_len = MHD_asprintf (&reply, |
395 | SECOND_PAGE, | 399 | SECOND_PAGE, |
396 | session->value_1, | 400 | session->value_1, |
397 | session->value_2)) | 401 | session->value_2); |
402 | if (0 > reply_len) | ||
398 | { | 403 | { |
399 | /* oops */ | 404 | /* oops */ |
400 | return MHD_NO; | 405 | return MHD_NO; |
401 | } | 406 | } |
402 | /* return static form */ | 407 | /* return static form */ |
403 | response = MHD_create_response_from_buffer (strlen (reply), | 408 | response = |
404 | (void *) reply, | 409 | MHD_create_response_from_buffer_with_free_callback (reply_len, |
405 | MHD_RESPMEM_MUST_FREE); | 410 | (void *) reply, |
411 | &free); | ||
406 | add_session_cookie (session, response); | 412 | add_session_cookie (session, response); |
407 | MHD_add_response_header (response, | 413 | MHD_add_response_header (response, |
408 | MHD_HTTP_HEADER_CONTENT_ENCODING, | 414 | MHD_HTTP_HEADER_CONTENT_ENCODING, |