Free basic requests using free_basic_request
This commit is contained in:
parent
e93c07a0a2
commit
b89ec823b8
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue