From 1b5e488b4565138756254aa2ec7e3f07a8a70c9d Mon Sep 17 00:00:00 2001 From: Patrick Lipka Date: Thu, 7 Aug 2025 16:05:40 +0200 Subject: [PATCH] Add dynamic array structure --- src/rvprof_internal.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/rvprof_internal.h b/src/rvprof_internal.h index c8457ff..aa6234d 100644 --- a/src/rvprof_internal.h +++ b/src/rvprof_internal.h @@ -58,7 +58,7 @@ typedef struct { char caller [MAX_NAME_LEN]; uint64_t total_inclusive_time; uint64_t total_exclusive_time; - uint64_t total_inclusive_cycles; + uint64_t total_inclusive_cycles; uint64_t total_exclusive_cycles; uint64_t call_count; int* stack_ids; @@ -71,6 +71,18 @@ typedef struct { double inclusive_percent; } function_stats_t; +// dynamic array structure (could switch to a more sophisticated container + template if we would move to C++ at some point) +#define DECLARE_DYNAMIC_ARRAY(type, name) \ +typedef struct { \ + type* data; \ + int size; \ + int capacity; \ +} name##_array_t; + +DECLARE_DYNAMIC_ARRAY(region_t, region); +DECLARE_DYNAMIC_ARRAY(function_stats_t, function_stats); +DECLARE_DYNAMIC_ARRAY(symbol_entry_t, symbol); + #ifdef __cplusplus } #endif