3 ms·
"I always find it amusing when I write something that spends a bunch of work making sure everything is freed before it exits." Yeah, just exit! That's the kin
by t1m 13y ago
"I always find it amusing when I write something that spends a bunch of work making sure everything is freed before it exits."
Yeah, just exit! That's the kind of cool thing about these small, short lived Unix programs like grep and cat - chew memory (stack or heap, up to you!) and bail out - let the OS clean it up. It is essentially the same argument as "prefer large mallocs to small" - the process itself is a 'large malloc'.
- dllthomas 13y agoRight. Like I said, the reason to go to the (programming) effort is that I can make sure it valgrinds clean, which means (if I'm being moderately smart along the way) that I'm not dropping things on the floor that I don't mean to during the program run when I still care about it. Adding a flag for "I don't care about valgrind, go ahead and exit" is then a tiny bit of extra programmer work to save the processor a bit of extra work each run; not sure it's worth it but not sure it's not.
- t1m 13y agoValgrind looks like an amazing tool. I am still a bit giddy to use a C with function prototypes, // style comments and enums, to be honest.
- dllthomas 13y agoValgrind and friends are great. splint has been useful, but needs c99 (and now c11) support. Tangential, but one thing I've recently taken to doing in my C is basically avoiding bare primitive types, preferring to wrap them in a single element struct. This means I can't pass, for instance, price where I mean quantity just because they're "both numbers".