From b3f3a0de3b34ab0650228f4341c347f88c123420 Mon Sep 17 00:00:00 2001 From: Daan Leijen Date: Sun, 5 Mar 2023 22:22:36 -0800 Subject: [PATCH 1/3] include psapi.h instead of defining PROCESS_MEMORY_COUNTERS on windows --- src/heap.c | 2 ++ src/stats.c | 14 +------------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/heap.c b/src/heap.c index 6fe1fb17..94fed2b5 100644 --- a/src/heap.c +++ b/src/heap.c @@ -311,11 +311,13 @@ void _mi_heap_destroy_pages(mi_heap_t* heap) { mi_heap_reset_pages(heap); } +#if MI_TRACK_HEAP_DESTROY static bool mi_cdecl mi_heap_track_block_free(const mi_heap_t* heap, const mi_heap_area_t* area, void* block, size_t block_size, void* arg) { MI_UNUSED(heap); MI_UNUSED(area); MI_UNUSED(arg); MI_UNUSED(block_size); mi_track_free_size(block,mi_usable_size(block)); return true; } +#endif void mi_heap_destroy(mi_heap_t* heap) { mi_assert(heap != NULL); diff --git a/src/stats.c b/src/stats.c index 363c4400..84d677fa 100644 --- a/src/stats.c +++ b/src/stats.c @@ -465,6 +465,7 @@ mi_msecs_t _mi_clock_end(mi_msecs_t start) { #if defined(_WIN32) #include +#include static mi_msecs_t filetime_msecs(const FILETIME* ftime) { ULARGE_INTEGER i; @@ -474,19 +475,6 @@ static mi_msecs_t filetime_msecs(const FILETIME* ftime) { return msecs; } -typedef struct _PROCESS_MEMORY_COUNTERS { - DWORD cb; - DWORD PageFaultCount; - SIZE_T PeakWorkingSetSize; - SIZE_T WorkingSetSize; - SIZE_T QuotaPeakPagedPoolUsage; - SIZE_T QuotaPagedPoolUsage; - SIZE_T QuotaPeakNonPagedPoolUsage; - SIZE_T QuotaNonPagedPoolUsage; - SIZE_T PagefileUsage; - SIZE_T PeakPagefileUsage; -} PROCESS_MEMORY_COUNTERS; -typedef PROCESS_MEMORY_COUNTERS* PPROCESS_MEMORY_COUNTERS; typedef BOOL (WINAPI *PGetProcessMemoryInfo)(HANDLE, PPROCESS_MEMORY_COUNTERS, DWORD); static PGetProcessMemoryInfo pGetProcessMemoryInfo = NULL; From e912697d90fef95ff9004ee4a9543d333dbb128c Mon Sep 17 00:00:00 2001 From: Daan Leijen Date: Sun, 5 Mar 2023 22:26:05 -0800 Subject: [PATCH 2/3] fix warning with zero padding --- src/page.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/page.c b/src/page.c index 70cb0d89..3205f975 100644 --- a/src/page.c +++ b/src/page.c @@ -856,7 +856,7 @@ static mi_page_t* mi_find_page(mi_heap_t* heap, size_t size, size_t huge_alignme } else { // otherwise find a page with free blocks in our size segregated queues - mi_assert_internal(size >= MI_PADDING_SIZE); + mi_assert_internal((ptrdiff_t)size >= MI_PADDING_SIZE); // cast to signed to avoid error if there is no padding return mi_find_free_page(heap, size); } } From 64fb009695a7e659059d6ea8c36bb23cee141193 Mon Sep 17 00:00:00 2001 From: Daan Leijen Date: Sun, 5 Mar 2023 22:27:45 -0800 Subject: [PATCH 3/3] fix warning with zero padding --- src/page.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/page.c b/src/page.c index 3205f975..46dfd26f 100644 --- a/src/page.c +++ b/src/page.c @@ -856,7 +856,9 @@ static mi_page_t* mi_find_page(mi_heap_t* heap, size_t size, size_t huge_alignme } else { // otherwise find a page with free blocks in our size segregated queues - mi_assert_internal((ptrdiff_t)size >= MI_PADDING_SIZE); // cast to signed to avoid error if there is no padding + #if MI_PADDING + mi_assert_internal(size >= MI_PADDING_SIZE); + #endif return mi_find_free_page(heap, size); } }