diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-10-09 22:41:11 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-10-09 22:41:11 +0200 |
commit | 330a40552cbd26ebcdf25bf209e12697ac330737 (patch) | |
tree | 7db9138ce0dfb398aae4aa560ea43cbe3baeedd6 /doc | |
parent | 181ac3c59fffd599cd6b351940bffd5c6c930fd7 (diff) | |
download | libmicrohttpd-330a40552cbd26ebcdf25bf209e12697ac330737.tar.gz libmicrohttpd-330a40552cbd26ebcdf25bf209e12697ac330737.zip |
add MHD_free(), as suggested by Tim on the mailinglist
Diffstat (limited to 'doc')
-rw-r--r-- | doc/examples/basicauthentication.c | 11 | ||||
-rw-r--r-- | doc/libmicrohttpd.texi | 10 |
2 files changed, 13 insertions, 8 deletions
diff --git a/doc/examples/basicauthentication.c b/doc/examples/basicauthentication.c index 0e13a2ee..88cb79b7 100644 --- a/doc/examples/basicauthentication.c +++ b/doc/examples/basicauthentication.c | |||
@@ -42,12 +42,13 @@ answer_to_connection (void *cls, struct MHD_Connection *connection, | |||
42 | return MHD_YES; | 42 | return MHD_YES; |
43 | } | 43 | } |
44 | pass = NULL; | 44 | pass = NULL; |
45 | user = MHD_basic_auth_get_username_password (connection, &pass); | 45 | user = MHD_basic_auth_get_username_password (connection, |
46 | fail = ( (user == NULL) || | 46 | &pass); |
47 | fail = ( (NULL == user) || | ||
47 | (0 != strcmp (user, "root")) || | 48 | (0 != strcmp (user, "root")) || |
48 | (0 != strcmp (pass, "pa$$w0rd") ) ); | 49 | (0 != strcmp (pass, "pa$$w0rd") ) ); |
49 | if (user != NULL) free (user); | 50 | if (NULL != user) MHD_free (user); |
50 | if (pass != NULL) free (pass); | 51 | if (NULL != pass) MHD_free (pass); |
51 | if (fail) | 52 | if (fail) |
52 | { | 53 | { |
53 | const char *page = "<html><body>Go away.</body></html>"; | 54 | const char *page = "<html><body>Go away.</body></html>"; |
diff --git a/doc/libmicrohttpd.texi b/doc/libmicrohttpd.texi index 05b1f834..2e0f196f 100644 --- a/doc/libmicrohttpd.texi +++ b/doc/libmicrohttpd.texi | |||
@@ -2342,13 +2342,17 @@ client certificates is presented in the MHD tutorial. | |||
2342 | @node microhttpd-dauth basic | 2342 | @node microhttpd-dauth basic |
2343 | @section Using Basic Authentication | 2343 | @section Using Basic Authentication |
2344 | 2344 | ||
2345 | @deftypefun {void} MHD_free (void *ptr) | ||
2346 | Free the memory given at @code{ptr}. Used to free data structures allocated by MHD. Calls @code{free(ptr)}. | ||
2347 | @end deftypefun | ||
2348 | |||
2345 | @deftypefun {char *} MHD_basic_auth_get_username_password (struct MHD_Connection *connection, char** password) | 2349 | @deftypefun {char *} MHD_basic_auth_get_username_password (struct MHD_Connection *connection, char** password) |
2346 | Get the username and password from the basic authorization header sent by the client. | 2350 | Get the username and password from the basic authorization header sent by the client. |
2347 | Return @code{NULL} if no username could be found, a pointer to the username if found. | 2351 | Return @code{NULL} if no username could be found, a pointer to the username if found. |
2348 | If returned value is not @code{NULL}, the value must be @code{free()}'ed. | 2352 | If returned value is not @code{NULL}, the value must be @code{MHD_free()}'ed. |
2349 | 2353 | ||
2350 | @var{password} reference a buffer to store the password. It can be @code{NULL}. | 2354 | @var{password} reference a buffer to store the password. It can be @code{NULL}. |
2351 | If returned value is not @code{NULL}, the value must be @code{free()}'ed. | 2355 | If returned value is not @code{NULL}, the value must be @code{MHD_free()}'ed. |
2352 | @end deftypefun | 2356 | @end deftypefun |
2353 | 2357 | ||
2354 | @deftypefun {int} MHD_queue_basic_auth_fail_response (struct MHD_Connection *connection, const char *realm, struct MHD_Response *response) | 2358 | @deftypefun {int} MHD_queue_basic_auth_fail_response (struct MHD_Connection *connection, const char *realm, struct MHD_Response *response) |
@@ -2370,7 +2374,7 @@ client with a 401 HTTP status. | |||
2370 | @deftypefun {char *} MHD_digest_auth_get_username (struct MHD_Connection *connection) | 2374 | @deftypefun {char *} MHD_digest_auth_get_username (struct MHD_Connection *connection) |
2371 | Find and return a pointer to the username value from the request header. | 2375 | Find and return a pointer to the username value from the request header. |
2372 | Return @code{NULL} if the value is not found or header does not exist. | 2376 | Return @code{NULL} if the value is not found or header does not exist. |
2373 | If returned value is not @code{NULL}, the value must be @code{free()}'ed. | 2377 | If returned value is not @code{NULL}, the value must be @code{MHD_free()}'ed. |
2374 | @end deftypefun | 2378 | @end deftypefun |
2375 | 2379 | ||
2376 | @deftypefun int MHD_digest_auth_check (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, unsigned int nonce_timeout) | 2380 | @deftypefun int MHD_digest_auth_check (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, unsigned int nonce_timeout) |