diff -x Makefile -x .deps -x '*.rc' -ur libmicrohttpd-0.9.65/src/include/microhttpd.h libmicrohttpd/src/include/microhttpd.h --- libmicrohttpd-0.9.65/src/include/microhttpd.h 2019-07-05 16:21:24.000000000 -0400 +++ libmicrohttpd/src/include/microhttpd.h 2019-07-21 22:03:05.388191487 -0400 @@ -2887,11 +2887,24 @@ /** * End of the list of options. */ - MHD_RO_END = 0 + MHD_RO_END = 0, + + /** + * Set a specific free() function + * to free response buffer instead of libc void free(void * ptr) + */ + MHD_RO_FREE_FUNCTION = 0 }; /** + * This typedef is defined to be able to pass a function pointer + * as a va_arg in MHD_set_response_options + */ +typedef void(*MHD_free_ptr)(void *); + + +/** * Set special flags and options for a response. * * @param response the response to modify diff -x Makefile -x .deps -x '*.rc' -ur libmicrohttpd-0.9.65/src/microhttpd/response.c libmicrohttpd/src/microhttpd/response.c --- libmicrohttpd-0.9.65/src/microhttpd/response.c 2019-06-23 15:20:42.000000000 -0400 +++ libmicrohttpd/src/microhttpd/response.c 2019-07-21 21:51:46.837784832 -0400 @@ -400,7 +400,6 @@ return response; } - /** * Set special flags and options for a response. * @@ -425,6 +424,15 @@ { switch (ro) { + case MHD_RO_FREE_FUNCTION: + va_start (ap, flags); + if (NULL != (response->crfc = va_arg (ap, MHD_free_ptr))) { + ret = MHD_YES; + } else { + ret = MHD_NO; + } + va_end (ap); + break; default: ret = MHD_NO; break;