SUNET
SUNET copied to clipboard
memory leak 2
I found this code:
int main() {
sub_framework::Request* request = new sub_framework::Request();
sub_framework::HttpParser* http_parser = new sub_framework::HttpParser();
char *recv_buf = "";
http_parser->_parse(recv_buf, *request);
return 0;
}
Valgrind would flag that as a memory leak, consider allocating the request and parser in the stack instead:
int main() {
sub_framework::Request request;
sub_framework::HttpParser http_parser;
char *recv_buf = "";
http_parser->_parse(recv_buf, *request);
return 0;
}
or use smart pointers instead of raw pointers.