[BusyBox] Clean up
Tito
farmatito at tiscali.it
Tue Jul 26 21:36:35 UTC 2005
Hi,
one more funny solution:
/* in config.h */
#define CONFIG_FEATURE_CLEAN_UP
/* in busybox.h ? */
#ifdef CONFIG_FEATURE_CLEAN_UP
#include <stdio.h> /* maybe not needed */
#include <unistd.h> /* maybe not needed */
#include <stdlib.h> /* maybe not needed */
#define clean_up_free(x) free(x)
#define clean_up_close(x) close(x)
#define clean_up_fclose(x) fclose(x)
/* something else needed here ? */
#else
#define clean_up_free(x)
#define clean_up_close(x)
#define clean_up_fclose(x)
#endif
/* test.c */
/*------------------------------------------------------------------*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
int main(int argc, char** argv) {
int fd;
char * ptr;
ptr = malloc(4);
fd = open("test_file", O_RDONLY);
clean_up_close(fd);
clean_up_free(ptr);
exit(0);
}
/*---------------------------------------------------------------------*/
root at localhost:/dev/pts/2:/root# size test_with_cleanup
text data bss dec hex filename
1147 272 4 1423 58f test
root at localhost:/dev/pts/2:/root# size test_without_cleanup
text data bss dec hex filename
1012 264 4 1280 500 test
So this is very flexible, multiline friendly and almost understandable.....
for me at least ;-)
Ciao,
Tito
More information about the busybox
mailing list