Migrated printf_hook_t to INIT/METHOD macros

This commit is contained in:
Andreas Steffen
2010-12-02 06:17:24 +01:00
parent 779e797a50
commit 0ff4942f85
+11 -11
View File
@@ -377,10 +377,8 @@ int vstr_wrapper_vasprintf(char **str, const char *format, va_list args)
} }
#endif #endif
/** METHOD(printf_hook_t, add_handler, void,
* Implementation of printf_hook_t.add_handler. private_printf_hook_t *this, char spec,
*/
static void add_handler(private_printf_hook_t *this, char spec,
printf_hook_function_t hook, ...) printf_hook_function_t hook, ...)
{ {
int i = -1; int i = -1;
@@ -439,10 +437,8 @@ static void add_handler(private_printf_hook_t *this, char spec,
} }
} }
/** METHOD(printf_hook_t, destroy, void,
* Implementation of printf_hook_t.destroy private_printf_hook_t *this)
*/
static void destroy(private_printf_hook_t *this)
{ {
int i; int i;
#ifdef USE_VSTR #ifdef USE_VSTR
@@ -477,10 +473,14 @@ static void destroy(private_printf_hook_t *this)
*/ */
printf_hook_t *printf_hook_create() printf_hook_t *printf_hook_create()
{ {
private_printf_hook_t *this = malloc_thing(private_printf_hook_t); private_printf_hook_t *this;
this->public.add_handler = (void(*)(printf_hook_t*, char, printf_hook_function_t, ...))add_handler; INIT(this,
this->public.destroy = (void(*)(printf_hook_t*))destroy; .public = {
.add_handler = _add_handler,
.destroy = _destroy,
},
);
memset(printf_hooks, 0, sizeof(printf_hooks)); memset(printf_hooks, 0, sizeof(printf_hooks));