[flashrom] [PATCH] Fix flashrom memory leaks
ron minnich
rminnich at gmail.com
Fri Sep 18 23:30:42 CEST 2009
OK, if you're going to do this:
if (x) {
message
exit
}
all over the place, why not do this instead:
void *xalloc(size_t amount, char *msg)
{
void *ret = alloc(amount);
if (! ret) {
fprintf(stderr, "%s: Alloc of %d bytes failed\n", msg, amount);
exit(1);
}
}
same for realloc.
Why? because:
1. you're repeating the same code over and over
2. you're not telling people where you failed, or how much you tried to allocate
this kind of fatal error should be informative
just a comment
ron
More information about the flashrom
mailing list