2 ms·
This solution did not override "free" to free the extra struct, so calling free is in fact not optional but probably a bad idea. Need an extra patch: #def
by omoikane 3y ago
This solution did not override "free" to free the extra struct, so calling free is in fact not optional but probably a bad idea. Need an extra patch:
#define free(_) /* no-op */
- hamburglar 3y agoBest criticism to this tongue-in-cheek solution yet. I’ll add my own more minor criticism: it will explode if the leaksaver struct allocation ever fails because it doesn’t check the result. That does it. I am not going to use it.
- junon 3y agoNitpick: for maximum source compatibility, use this instead: #define free(_) ((void)0)
- huhtenberg 3y agoTechnically _ needs to be evaluated by the macro to support cases like free(p++).
- junon 3y agohmm right... wouldn't this work then? #define free(e) ((void)(e))