Added optional pointer return in TraceNextN

This commit is contained in:
VegOwOtenks 2024-10-16 17:25:33 +02:00
parent d3722aac83
commit 840b19adf2
2 changed files with 9 additions and 6 deletions

View file

@ -158,10 +158,12 @@ int TracingHeap_TraceNext(TracingHeap* self)
return EXIT_SUCCESS;
}
size_t TracingHeap_TraceNextN(TracingHeap* self, size_t n)
size_t TracingHeap_TraceNextN(TracingHeap* self, size_t n, int* error_code)
{
for (size_t i = 0; i < n; i++) {
if (TracingHeap_TraceNext(self)) {
int trace_code = TracingHeap_TraceNext(self);
if (trace_code != EXIT_SUCCESS) {
if (error_code != NULL) *error_code = trace_code;
return i;
}
}

View file

@ -49,16 +49,17 @@ typedef struct TracingHeap_s {
allocator_t* allocator;
} TracingHeap;
int TracingHeap_Create(TracingHeap* self, allocator_t* allocator);
void TracingHeap_Destroy(TracingHeap* self);
int TracingHeap_Create(TracingHeap* self, allocator_t* allocator);
void TracingHeap_Destroy(TracingHeap* self);
void* TracingHeap_Allocate(TracingHeap* self, size_t bytes);
void* TracingHeap_Allocate(TracingHeap* self, size_t bytes);
int TracingHeap_BeginTrace(TracingHeap* self);
bool TracingHeap_IsTraceFinished(TracingHeap* self);
int TracingHeap_EndTrace(TracingHeap* self);
int TracingHeap_TraceNext(TracingHeap* self);
size_t TracingHeap_TraceNextN(TracingHeap* self, size_t n);
size_t TracingHeap_TraceNextN(TracingHeap* self, size_t n, int* error_code);
int TracingHeap_AddTracingRoot(TracingHeap* self, void* data);
#endif // header