aboutsummaryrefslogtreecommitdiff
path: root/src/examples
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-10-09 22:41:11 +0200
committerChristian Grothoff <christian@grothoff.org>2017-10-09 22:41:11 +0200
commit330a40552cbd26ebcdf25bf209e12697ac330737 (patch)
tree7db9138ce0dfb398aae4aa560ea43cbe3baeedd6 /src/examples
parent181ac3c59fffd599cd6b351940bffd5c6c930fd7 (diff)
downloadlibmicrohttpd-330a40552cbd26ebcdf25bf209e12697ac330737.tar.gz
libmicrohttpd-330a40552cbd26ebcdf25bf209e12697ac330737.zip
add MHD_free(), as suggested by Tim on the mailinglist
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/authorization_example.c11
-rw-r--r--src/examples/digest_auth_example.c5
2 files changed, 10 insertions, 6 deletions
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,
70 70
71 /* require: "Aladdin" with password "open sesame" */ 71 /* require: "Aladdin" with password "open sesame" */
72 pass = NULL; 72 pass = NULL;
73 user = MHD_basic_auth_get_username_password (connection, &pass); 73 user = MHD_basic_auth_get_username_password (connection,
74 fail = ( (user == NULL) || (0 != strcmp (user, "Aladdin")) || (0 != strcmp (pass, "open sesame") ) ); 74 &pass);
75 fail = ( (NULL == user) ||
76 (0 != strcmp (user, "Aladdin")) ||
77 (0 != strcmp (pass, "open sesame") ) );
75 if (fail) 78 if (fail)
76 { 79 {
77 response = MHD_create_response_from_buffer (strlen (DENIED), 80 response = MHD_create_response_from_buffer (strlen (DENIED),
@@ -87,9 +90,9 @@ ahc_echo (void *cls,
87 ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 90 ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
88 } 91 }
89 if (NULL != user) 92 if (NULL != user)
90 free (user); 93 MHD_free (user);
91 if (NULL != pass) 94 if (NULL != pass)
92 free (pass); 95 MHD_free (pass);
93 MHD_destroy_response (response); 96 MHD_destroy_response (response);
94 return ret; 97 return ret;
95} 98}
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,
54 (void)ptr; /* Unused. Silent compiler warning. */ 54 (void)ptr; /* Unused. Silent compiler warning. */
55 55
56 username = MHD_digest_auth_get_username(connection); 56 username = MHD_digest_auth_get_username(connection);
57 if (username == NULL) 57 if (NULL == username)
58 { 58 {
59 response = MHD_create_response_from_buffer(strlen (DENIED), 59 response = MHD_create_response_from_buffer(strlen (DENIED),
60 DENIED, 60 DENIED,
@@ -70,7 +70,7 @@ ahc_echo (void *cls,
70 username, 70 username,
71 password, 71 password,
72 300); 72 300);
73 free(username); 73 MHD_free (username);
74 if ( (ret == MHD_INVALID_NONCE) || 74 if ( (ret == MHD_INVALID_NONCE) ||
75 (ret == MHD_NO) ) 75 (ret == MHD_NO) )
76 { 76 {
@@ -93,6 +93,7 @@ ahc_echo (void *cls,
93 return ret; 93 return ret;
94} 94}
95 95
96
96int 97int
97main (int argc, char *const *argv) 98main (int argc, char *const *argv)
98{ 99{