mirror of
https://github.com/xzeldon/htop.git
synced 2025-01-31 09:07:25 +03:00
be568b1153
Improves stacktraces. Current stacktrace: ./htop(backtrace+0x5b)[0x45d98b] ./htop(CRT_handleSIGSEGV+0x189)[0x4eb5e9] /lib/x86_64-linux-gnu/libpthread.so.0(+0x14140)[0x7fbbfb1ea140] New: ./htop(backtrace+0x5b)[0x45d98b] ./htop(CRT_handleSIGSEGV+0x189)[0x4eb7f9] /lib/x86_64-linux-gnu/libpthread.so.0(+0x14140)[0x7f62b0a65140] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x141)[0x7f62b089ac41] /lib/x86_64-linux-gnu/libc.so.6(abort+0x123)[0x7f62b0884537] /lib/x86_64-linux-gnu/libc.so.6(+0x2540f)[0x7f62b088440f] /lib/x86_64-linux-gnu/libc.so.6(+0x345c2)[0x7f62b08935c2] ./htop(Vector_delete+0x873)[0x54b303] ./htop(Panel_done+0x7b)[0x51abbb] ./htop[0x4ed8ee] ./htop(Vector_delete+0x414)[0x54aea4] ./htop(ScreenManager_delete+0x37)[0x536ea7] ./htop[0x4d9d1a] ./htop[0x4d5516] ./htop[0x5078d7] ./htop(ScreenManager_run+0x69f)[0x5388bf] ./htop(main+0x7c6)[0x4fcf76] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xea)[0x7f62b0885cca] ./htop(_start+0x2a)[0x42688a]
67 lines
1.8 KiB
C
67 lines
1.8 KiB
C
#ifndef HEADER_Object
|
|
#define HEADER_Object
|
|
/*
|
|
htop - Object.h
|
|
(C) 2004-2012 Hisham H. Muhammad
|
|
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
|
Released under the GNU GPLv2, see the COPYING file
|
|
in the source distribution for its full text.
|
|
*/
|
|
|
|
#include "config.h" // IWYU pragma: keep
|
|
|
|
#include <assert.h>
|
|
|
|
#include "RichString.h"
|
|
#include "XUtils.h" // IWYU pragma: keep
|
|
|
|
#ifndef NDEBUG
|
|
#include <stdbool.h>
|
|
#endif
|
|
|
|
|
|
struct Object_;
|
|
typedef struct Object_ Object;
|
|
|
|
typedef void(*Object_Display)(const Object*, RichString*);
|
|
typedef long(*Object_Compare)(const void*, const void*);
|
|
typedef void(*Object_Delete)(Object*);
|
|
|
|
#define Object_getClass(obj_) ((const Object*)(obj_))->klass
|
|
#define Object_setClass(obj_, class_) (((Object*)(obj_))->klass = (const ObjectClass*) (class_))
|
|
|
|
#define Object_delete(obj_) (assert(Object_getClass(obj_)->delete), Object_getClass(obj_)->delete((Object*)(obj_)))
|
|
#define Object_displayFn(obj_) Object_getClass(obj_)->display
|
|
#define Object_display(obj_, str_) (assert(Object_getClass(obj_)->display), Object_getClass(obj_)->display((const Object*)(obj_), str_))
|
|
#define Object_compare(obj_, other_) (assert(Object_getClass(obj_)->compare), Object_getClass(obj_)->compare((const void*)(obj_), other_))
|
|
|
|
#define Class(class_) ((const ObjectClass*)(&(class_ ## _class)))
|
|
|
|
#define AllocThis(class_) (class_*) xMalloc(sizeof(class_)); Object_setClass(this, Class(class_))
|
|
|
|
typedef struct ObjectClass_ {
|
|
const void* const extends;
|
|
const Object_Display display;
|
|
const Object_Delete delete;
|
|
const Object_Compare compare;
|
|
} ObjectClass;
|
|
|
|
struct Object_ {
|
|
const ObjectClass* klass;
|
|
};
|
|
|
|
typedef union {
|
|
int i;
|
|
void* v;
|
|
} Arg;
|
|
|
|
extern const ObjectClass Object_class;
|
|
|
|
#ifndef NDEBUG
|
|
|
|
bool Object_isA(const Object* o, const ObjectClass* klass);
|
|
|
|
#endif /* NDEBUG */
|
|
|
|
#endif
|