Object | +---DAtExit
The AtExit implements a number of methods for insuring the freeing of objects during the exit of the program. This class has only class methods (singleton).
#include <stdio.h> #include "ofc/DAtExit.h" #include "ofc/DFile.h" int main(int argc, char *argv[]) { DFile *file = [DFile new]; if ([file open :"example.ini" :"r"]) { [DAtExit add :file]; // If program exit, then automatically call [file free] // Read the file .. [file close]; [DAtExit remove :file]; // If program exit, [file free] is not called anymore } [file free]; return 0; }