[BusyBox] Clean up
Erik Andersen
andersen at codepoet.org
Tue Jul 26 21:56:52 UTC 2005
On Tue Jul 26, 2005 at 11:36:35PM +0200, Tito wrote:
> 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
That works too, though I'd prefer implementing such a thing
using static inline functions to avoid the potential for macro
expansion bugs...
i.e....
#ifdef CONFIG_FEATURE_CLEAN_UP
static inline void clean_up_free(void *foo) { free(foo); }
#else
static inline void clean_up_free(void *foo) { }
#endif
-Erik
--
Erik B. Andersen http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--
More information about the busybox
mailing list