Defer: Resource cleanup in C with GCCs magic
1–10 of 99 posts
Re: Defer: Resource cleanup in C with GCCs magic
#2Re: Defer: Resource cleanup in C with GCCs magic
#3Re: Defer: Resource cleanup in C with GCCs magic
#4[0] https://thephd.dev/c2y-the-defer-technical-specification-its...
Re: Defer: Resource cleanup in C with GCCs magic
#5> If malloc fails and returns NULL, the cleanup function will still be called, and there’s no simple way to add a guard inside free_ptr.
free(NULL) is a no-op, this is a non-issue. I don't know what's so hard about a single if statement anyway even if this were an issue.
Re: Defer: Resource cleanup in C with GCCs magic
#6I don't understand why people insist on simulating a poor substitute for RAII with a feature that is itself almost decent RAII. > If malloc fails and returns NULL, the cleanup function will still be called, and there’s no simple way to add a guard inside free_ptr. free(NULL) is a no-op, this is a non-issue. I don't know what's so hard about a single if statement anyway even if this were an issue.
Re: Defer: Resource cleanup in C with GCCs magic
#7Seems good, but I do not care about cleanup memory since I started to use arenas.
Re: Defer: Resource cleanup in C with GCCs magic
#8Seems good, but I do not care about cleanup memory since I started to use arenas.
Re: Defer: Resource cleanup in C with GCCs magic
#9I don't understand why people insist on simulating a poor substitute for RAII with a feature that is itself almost decent RAII. > If malloc fails and returns NULL, the cleanup function will still be called, and there’s no simple way to add a guard inside free_ptr. free(NULL) is a no-op, this is a non-issue. I don't know what's so hard about a single if statement anyway even if this were an issue.
`free(NULL);` will crash on some platforms that gcc supports, I believe.
>If ptr is a null pointer, no action occurs.
Re: Defer: Resource cleanup in C with GCCs magic
#10I don't understand why people insist on simulating a poor substitute for RAII with a feature that is itself almost decent RAII. > If malloc fails and returns NULL, the cleanup function will still be called, and there’s no simple way to add a guard inside free_ptr. free(NULL) is a no-op, this is a non-issue. I don't know what's so hard about a single if statement anyway even if this were an issue.
`free(NULL);` will crash on some platforms that gcc supports, I believe.