From 330a40552cbd26ebcdf25bf209e12697ac330737 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 9 Oct 2017 22:41:11 +0200 Subject: add MHD_free(), as suggested by Tim on the mailinglist --- src/examples/authorization_example.c | 11 +++++++---- src/examples/digest_auth_example.c | 5 +++-- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src/examples') diff --git a/src/examples/authorization_example.c b/src/examples/authorization_example.c index d62973a2..d8a88203 100644 --- a/src/examples/authorization_example.c +++ b/src/examples/authorization_example.c @@ -70,8 +70,11 @@ ahc_echo (void *cls, /* require: "Aladdin" with password "open sesame" */ pass = NULL; - user = MHD_basic_auth_get_username_password (connection, &pass); - fail = ( (user == NULL) || (0 != strcmp (user, "Aladdin")) || (0 != strcmp (pass, "open sesame") ) ); + user = MHD_basic_auth_get_username_password (connection, + &pass); + fail = ( (NULL == user) || + (0 != strcmp (user, "Aladdin")) || + (0 != strcmp (pass, "open sesame") ) ); if (fail) { response = MHD_create_response_from_buffer (strlen (DENIED), @@ -87,9 +90,9 @@ ahc_echo (void *cls, ret = MHD_queue_response (connection, MHD_HTTP_OK, response); } if (NULL != user) - free (user); + MHD_free (user); if (NULL != pass) - free (pass); + MHD_free (pass); MHD_destroy_response (response); return ret; } diff --git a/src/examples/digest_auth_example.c b/src/examples/digest_auth_example.c index 4b00669f..889967fb 100644 --- a/src/examples/digest_auth_example.c +++ b/src/examples/digest_auth_example.c @@ -54,7 +54,7 @@ ahc_echo (void *cls, (void)ptr; /* Unused. Silent compiler warning. */ username = MHD_digest_auth_get_username(connection); - if (username == NULL) + if (NULL == username) { response = MHD_create_response_from_buffer(strlen (DENIED), DENIED, @@ -70,7 +70,7 @@ ahc_echo (void *cls, username, password, 300); - free(username); + MHD_free (username); if ( (ret == MHD_INVALID_NONCE) || (ret == MHD_NO) ) { @@ -93,6 +93,7 @@ ahc_echo (void *cls, return ret; } + int main (int argc, char *const *argv) { -- cgit v1.2.3