Implemented TracingHeap_Destroy and TraceNextN
This commit is contained in:
parent
4f2a816128
commit
ccbe41c269
3 changed files with 127 additions and 23 deletions
|
@ -13,6 +13,7 @@ enum TracingColor {
|
|||
|
||||
typedef struct TracingObject {
|
||||
struct TracingObject* global_next;
|
||||
struct TracingObject* global_prev;
|
||||
struct TracingObject* color_next;
|
||||
struct TracingObject* color_prev;
|
||||
enum TracingColor color;
|
||||
|
@ -21,8 +22,21 @@ typedef struct TracingObject {
|
|||
alignas(void*) char data[];
|
||||
} TracingObject;
|
||||
|
||||
typedef int (*TraceReferenceCallback) (void* context, void* reference);
|
||||
typedef int (*ReferenceTracingFunction) (void* context, void* object, TraceReferenceCallback trace_callback, void* callback_context);
|
||||
typedef int (*TracingHeapVisit) (void* context, void* reference);
|
||||
typedef int (*TracingHeapTraceData) (void* context, void* data, TracingHeapVisit trace_callback, void* callback_context);
|
||||
typedef int (*TracingHeapDataDestructor) (void* context, void* data);
|
||||
typedef size_t (*TracingHeapSizeQuery) (void* context, void* data);
|
||||
|
||||
typedef struct TracingHeapConfig_s {
|
||||
TracingHeapTraceData trace_data;
|
||||
void* trace_context;
|
||||
|
||||
TracingHeapDataDestructor destructor;
|
||||
void* destructor_context;
|
||||
|
||||
TracingHeapSizeQuery size_query;
|
||||
void* size_query_context;
|
||||
} TracingHeapConfig;
|
||||
|
||||
typedef struct TracingHeap_s {
|
||||
TracingObject* objects;
|
||||
|
@ -30,20 +44,22 @@ typedef struct TracingHeap_s {
|
|||
TracingObject* grey_objects;
|
||||
TracingObject* black_objects;
|
||||
|
||||
ReferenceTracingFunction tracing_function;
|
||||
void* tracing_function_context;
|
||||
|
||||
enum TracingColor reachable_color;
|
||||
enum TracingColor unreachable_color;
|
||||
|
||||
TracingHeapConfig config;
|
||||
allocator_t* allocator;
|
||||
} TracingHeap;
|
||||
|
||||
int TracingHeap_Create(TracingHeap* self, ReferenceTracingFunction tracing_function, allocator_t* allocator);
|
||||
int TracingHeap_Create(TracingHeap* self, allocator_t* allocator);
|
||||
void TracingHeap_Destroy(TracingHeap* self);
|
||||
|
||||
void* TracingHeap_Allocate(TracingHeap* self, size_t bytes);
|
||||
|
||||
int TracingHeap_AddTracingRoot(TracingHeap* self, void* data);
|
||||
int TracingHeap_BeginTrace(TracingHeap* self);
|
||||
int TracingHeap_EndTrace(TracingHeap* self);
|
||||
int TracingHeap_TraceNext(TracingHeap* self);
|
||||
size_t TracingHeap_TraceNextN(TracingHeap* self, size_t n);
|
||||
int TracingHeap_AddTracingRoot(TracingHeap* self, void* data);
|
||||
|
||||
#endif // header
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue