|
|
|
|
|
by seodisparate
526 days ago
|
|
One can use C's `cleanup` attribute like a defer. https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attribute... The function signature is `void(MyType*)` if it is used like: __attribute__((cleanup(MyTypeCleanupFunction)))
MyType myType;
If it's a pointer, it'll call the cleanup as a double ptr, and etc.
Note that the specified cleanup function can do anything you want to, though the intended purpose is to cleanup the variable when it goes out of scope. |
|