#pragma once
#ifndef MIMALLOC_PROFILE_H
#define MIMALLOC_PROFILE_H
#include <mimalloc.h>
#include <stdbool.h>
#include <stdint.h>
#define MI_PROFILE_SAMPLE_DATA_MAX_SIZE (1024)
typedef struct mi_profiler_s mi_profiler_t;
typedef struct mi_profiler_sample_data_s {
size_t user_data_size; void* user_data[1]; } mi_profiler_sample_data_t;
typedef size_t (mi_cdecl mi_profiler_on_alloc_fun )(mi_profiler_t* profiler, mi_profiler_sample_data_t* profiler_data, void* ptr, size_t requested_size, size_t bytes_sample_rate, uint64_t bytes_since_last_sample, const mi_heap_t* heap);
typedef size_t (mi_cdecl mi_profiler_on_realloc_inplace_fun)(mi_profiler_t* profiler, mi_profiler_sample_data_t* profiler_data, void* ptr, size_t old_size, const mi_heap_t* heap);
typedef void (mi_cdecl mi_profiler_on_free_fun )(mi_profiler_t* profiler, mi_profiler_sample_data_t* profiler_data, void* ptr, const mi_heap_t* heap);
struct mi_profiler_s {
void* reserved; size_t sample_data_size; size_t initial_sample_rate; mi_profiler_on_alloc_fun* on_alloc; mi_profiler_on_free_fun* on_free; mi_profiler_on_realloc_inplace_fun* on_realloc_inplace; };
#ifdef __cplusplus
extern "C" {
#endif
mi_decl_export bool mi_heap_profile(mi_heap_t* heap, mi_profiler_t* profiler);
mi_decl_export void mi_heap_profile_disable(mi_heap_t* heap);
mi_decl_export bool mi_subproc_profile(mi_subproc_id_t subproc_id, mi_profiler_t* profiler);
mi_decl_export bool mi_profile(mi_profiler_t* profiler);
mi_decl_export bool mi_profiler_start(mi_profiler_t* profiler);
mi_decl_export bool mi_profiler_stop(mi_profiler_t* profiler);
#ifdef __cplusplus
}
#endif
#endif