Migrated backtrace_t to METHOD macro

This commit is contained in:
Martin Willi
2011-05-16 15:22:21 +02:00
parent 700296ccbe
commit 79edee7422
+11 -16
View File
@@ -50,10 +50,8 @@ struct private_backtrace_t {
void *frames[]; void *frames[];
}; };
/** METHOD(backtrace_t, log_, void,
* Implementation of backtrace_t.log private_backtrace_t *this, FILE *file, bool detailed)
*/
static void log_(private_backtrace_t *this, FILE *file, bool detailed)
{ {
#ifdef HAVE_BACKTRACE #ifdef HAVE_BACKTRACE
size_t i; size_t i;
@@ -129,11 +127,8 @@ static void log_(private_backtrace_t *this, FILE *file, bool detailed)
#endif /* HAVE_BACKTRACE */ #endif /* HAVE_BACKTRACE */
} }
/** METHOD(backtrace_t, contains_function, bool,
* Implementation of backtrace_t.contains_function private_backtrace_t *this, char *function[], int count)
*/
static bool contains_function(private_backtrace_t *this,
char *function[], int count)
{ {
#ifdef HAVE_DLADDR #ifdef HAVE_DLADDR
int i, j; int i, j;
@@ -157,10 +152,8 @@ static bool contains_function(private_backtrace_t *this,
return FALSE; return FALSE;
} }
/** METHOD(backtrace_t, destroy, void,
* Implementation of backtrace_t.destroy. private_backtrace_t *this)
*/
static void destroy(private_backtrace_t *this)
{ {
free(this); free(this);
} }
@@ -182,9 +175,11 @@ backtrace_t *backtrace_create(int skip)
memcpy(this->frames, frames + skip, frame_count * sizeof(void*)); memcpy(this->frames, frames + skip, frame_count * sizeof(void*));
this->frame_count = frame_count; this->frame_count = frame_count;
this->public.log = (void(*)(backtrace_t*,FILE*,bool))log_; this->public = (backtrace_t) {
this->public.contains_function = (bool(*)(backtrace_t*, char *function[], int count))contains_function; .log = _log_,
this->public.destroy = (void(*)(backtrace_t*))destroy; .contains_function = _contains_function,
.destroy = _destroy,
};
return &this->public; return &this->public;
} }