From aceea3ca1e17d1b091fd51cde3937aeebd27c972 Mon Sep 17 00:00:00 2001 From: "GitHub Actions[bot]" <> Date: Wed, 4 Feb 2026 06:43:43 +0000 Subject: [PATCH] Bot: Update dependencies --- .references/mimalloc | 2 +- mimalloc/include/mimalloc-stats.h | 10 +++++++--- mimalloc/include/mimalloc/types.h | 10 +++++----- mimalloc/src/init.c | 6 +++--- mimalloc/src/stats.c | 22 ++++++++++++++-------- 5 files changed, 30 insertions(+), 20 deletions(-) diff --git a/.references/mimalloc b/.references/mimalloc index 8f31ee2..400d7c8 100644 --- a/.references/mimalloc +++ b/.references/mimalloc @@ -1 +1 @@ -b69f9cb +8ff03b6 diff --git a/mimalloc/include/mimalloc-stats.h b/mimalloc/include/mimalloc-stats.h index 12c5c9a..be20fe7 100644 --- a/mimalloc/include/mimalloc-stats.h +++ b/mimalloc/include/mimalloc-stats.h @@ -11,7 +11,7 @@ terms of the MIT license. A copy of the license can be found in the file #include #include -#define MI_STAT_VERSION 3 // increased on every backward incompatible change +#define MI_STAT_VERSION 4 // increased on every backward incompatible change // count allocation over time typedef struct mi_stat_count_s { @@ -73,7 +73,8 @@ typedef struct mi_stat_counter_s { typedef struct mi_stats_s { - int version; + size_t size; // size of the mi_stats_t structure + size_t version; MI_STAT_FIELDS() @@ -89,12 +90,15 @@ typedef struct mi_stats_s #undef MI_STAT_COUNT #undef MI_STAT_COUNTER +// helper +#define mi_stats_t_decl(name) mi_stats_t name = { 0 }; name.size = sizeof(mi_stats_t); name.version = MI_STAT_VERSION; + // Exported definitions #ifdef __cplusplus extern "C" { #endif -mi_decl_export void mi_stats_get( size_t stats_size, mi_stats_t* stats ) mi_attr_noexcept; +mi_decl_export bool mi_stats_get( mi_stats_t* stats ) mi_attr_noexcept; mi_decl_export char* mi_stats_get_json( size_t buf_size, char* buf ) mi_attr_noexcept; // use mi_free to free the result if the input buf == NULL #ifdef __cplusplus diff --git a/mimalloc/include/mimalloc/types.h b/mimalloc/include/mimalloc/types.h index e778e87..eee8479 100644 --- a/mimalloc/include/mimalloc/types.h +++ b/mimalloc/include/mimalloc/types.h @@ -12,7 +12,7 @@ terms of the MIT license. A copy of the license can be found in the file // This file contains the main type definitions for mimalloc: // mi_heap_t : all data for a thread-local heap, contains // lists of all managed heap pages. -// mi_segment_t : a larger chunk of memory (32GiB) from where pages +// mi_segment_t : a larger chunk of memory (32MiB on 64-bit) from where pages // are allocated. A segment is divided in slices (64KiB) from // which pages are allocated. // mi_page_t : a "mimalloc" page (usually 64KiB or 512KiB) from @@ -63,9 +63,9 @@ terms of the MIT license. A copy of the license can be found in the file #define MI_SECURE 0 #endif -// Define MI_DEBUG for debug mode -// #define MI_DEBUG 1 // basic assertion checks and statistics, check double free, corrupted free list, and invalid pointer free. -// #define MI_DEBUG 2 // + internal assertion checks +// Define MI_DEBUG for assertion and invariant checking +// #define MI_DEBUG 1 // basic assertion checks and statistics, check double free, corrupted free list, and invalid pointer free. (cmake -DMI_DEBUG=ON) +// #define MI_DEBUG 2 // + internal assertion checks (cmake -DMI_DEBUG_INTERNAL=ON) // #define MI_DEBUG 3 // + extensive internal invariant checking (cmake -DMI_DEBUG_FULL=ON) #if !defined(MI_DEBUG) #if defined(MI_BUILD_RELEASE) || defined(NDEBUG) @@ -194,7 +194,7 @@ typedef int32_t mi_ssize_t; #define MI_SEGMENT_ALIGN MI_SEGMENT_SIZE #define MI_SEGMENT_MASK ((uintptr_t)(MI_SEGMENT_ALIGN - 1)) #define MI_SEGMENT_SLICE_SIZE (MI_ZU(1)<< MI_SEGMENT_SLICE_SHIFT) -#define MI_SLICES_PER_SEGMENT (MI_SEGMENT_SIZE / MI_SEGMENT_SLICE_SIZE) // 1024 +#define MI_SLICES_PER_SEGMENT (MI_SEGMENT_SIZE / MI_SEGMENT_SLICE_SIZE) // 512 (128 on 32-bit) #define MI_SMALL_PAGE_SIZE (MI_ZU(1)< sizeof(mi_stats_t) ? sizeof(mi_stats_t) : stats_size); - _mi_memcpy(stats, &_mi_stats_main, size); - stats->version = MI_STAT_VERSION; +bool mi_stats_get(mi_stats_t* stats) mi_attr_noexcept { + if (stats == NULL || stats->size != sizeof(mi_stats_t) || stats->version != MI_STAT_VERSION) return false; + _mi_memzero(stats,stats->size); + _mi_memcpy(stats, &_mi_stats_main, sizeof(mi_stats_t)); + return true; } @@ -589,7 +588,7 @@ char* mi_stats_get_json(size_t output_size, char* output_buf) mi_attr_noexcept { if (!mi_heap_buf_expand(&hbuf)) return NULL; } mi_heap_buf_print(&hbuf, "{\n"); - mi_heap_buf_print_value(&hbuf, "version", MI_STAT_VERSION); + mi_heap_buf_print_value(&hbuf, "stat_version", MI_STAT_VERSION); mi_heap_buf_print_value(&hbuf, "mimalloc_version", MI_MALLOC_VERSION); // process info @@ -629,5 +628,12 @@ char* mi_stats_get_json(size_t output_size, char* output_buf) mi_attr_noexcept { } mi_heap_buf_print(&hbuf, " ]\n"); mi_heap_buf_print(&hbuf, "}\n"); - return hbuf.buf; + if (hbuf.used >= hbuf.size) { + // failed + if (hbuf.can_realloc) { mi_free(hbuf.buf); } + return NULL; + } + else { + return hbuf.buf; + } }