3 ms·
not to use after free(); accidentally adding a second clause to a non-bracketed if expression; Two methods I religiously use in my code: Set to NULL after free
by Kenji 10y ago
not to use after free(); accidentally adding a second clause to a non-bracketed if expression;
Two methods I religiously use in my code: Set to NULL after freeing. free(NULL) is a no op, so freeing twice is never an issue anymore. And since you probably won't use the variable after that anyway, setting it to NULL eventually gets optimized out anyway, probably. And no if without brackets in my codebase.