Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generator: Fixed memory leak due to missing free() after malloc() in …
…get_configured_program() We want to uniformly use C++ functionality, hence replaced malloc() with new and added the missing delete.
- Loading branch information
d9e55d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you use
std::vector<char> program_name(256)
instead ofchar*
, and forget aboutdelete[]
altogether?d9e55d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an old enough piece of code I wrote at the time I was not aware that std::vector had little if no overhead. This is a very critical portion of the generator, since this is to be executed everytime an operation is launched, not just upon compilation... I probably got slightly paranoid when I wrote this piece of code (hence my initial malloc...) :)
d9e55d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case
char program_name[256]
should work faster thanmalloc()
:)d9e55d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, obviously! This piece of code is old, I was not sure whether or not 256 bytes would have been enough, when I wrote it! I'm starting to be ashamed now!
d9e55d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, the joy of picking other's code! :)