Free basic requests using free_basic_request

This commit is contained in:
Nick Krichevsky 2018-08-29 18:50:23 -04:00
parent e93c07a0a2
commit b89ec823b8
3 changed files with 12 additions and 1 deletions

View file

@ -35,8 +35,8 @@ int main(int argc, char* argv[]) {
struct http_message req = build_basic_request("GET", host_buffer, path_buffer, port_num);
char * req_result = send_request(req);
printf("%s", req_result);
free_basic_request(req);
free(req_result);
free(req.contents);
free(host_buffer);
free(path_buffer);
}

View file

@ -59,6 +59,16 @@ struct http_message build_basic_request(const char *method, const char *host, co
return message;
}
/**
* Free a request allocated by build_basic_request
*
* @param req A request allocated by build_basic_request
*/
void free_basic_request(struct http_message req) {
free(req.address);
free(req.path);
free(req.contents);
}
/**
* Get the address info for a given hostname and port.

View file

@ -8,6 +8,7 @@
#define MAX_PORT 65535
struct http_message build_basic_request(const char *method, const char *host, const char *path, int port);
void free_basic_request(struct http_message req);
char *send_request(struct http_message req);
#endif