diff --git a/src/TracingHeap/TracingHeap.c b/src/TracingHeap/TracingHeap.c index 1da3910..5be63b8 100644 --- a/src/TracingHeap/TracingHeap.c +++ b/src/TracingHeap/TracingHeap.c @@ -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; } } diff --git a/src/TracingHeap/TracingHeap.h b/src/TracingHeap/TracingHeap.h index aeb2dbc..cfe4c60 100644 --- a/src/TracingHeap/TracingHeap.h +++ b/src/TracingHeap/TracingHeap.h @@ -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