From 7817f8412d251d4a3abb72d4b706b60977a8a93b Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Sun, 19 Jan 2020 12:00:58 -0800 Subject: [PATCH] Trying to debug weird allocator crash bug; switching to windows --- custom/4coder_base_types.h | 3 +++ platform_mac/mac_4ed_functions.mm | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/custom/4coder_base_types.h b/custom/4coder_base_types.h index 715ccbf9..31f29195 100644 --- a/custom/4coder_base_types.h +++ b/custom/4coder_base_types.h @@ -531,6 +531,9 @@ union SNode{ #define zdll_remove_front(f,l) zdll_remove_back_NP_((l),(f),prev,next) #define zdll_remove(f,l,n) zdll_remove_NP_((f),(l),(n),next,prev) +#define zdll_assert_good(T,f) Stmnt( if (f != 0){ Assert(f->prev == 0); \ +for(T *p_ = f; p_ != 0; p_ = p_->next){ Assert(p_->prev == 0 || p_->prev->next == p_); Assert(p_->next == 0 || p_->next->prev == p_); } } ) + //////////////////////////////// union Vec2_i8{ diff --git a/platform_mac/mac_4ed_functions.mm b/platform_mac/mac_4ed_functions.mm index a0ab70ea..98ce3121 100644 --- a/platform_mac/mac_4ed_functions.mm +++ b/platform_mac/mac_4ed_functions.mm @@ -748,8 +748,10 @@ mac_memory_allocate_extended(void *base, u64 size, String_Const_u8 location){ pthread_mutex_lock(&memory_tracker_mutex); { + zdll_assert_good(Memory_Annotation_Tracker_Node, memory_tracker.first); zdll_push_back(memory_tracker.first, memory_tracker.last, node); memory_tracker.count += 1; + zdll_assert_good(Memory_Annotation_Tracker_Node, memory_tracker.first); } pthread_mutex_unlock(&memory_tracker_mutex); @@ -767,8 +769,10 @@ mac_memory_free_extended(void *ptr){ pthread_mutex_lock(&memory_tracker_mutex); { + zdll_assert_good(Memory_Annotation_Tracker_Node, memory_tracker.first); zdll_remove(memory_tracker.first, memory_tracker.last, node); memory_tracker.count -= 1; + zdll_assert_good(Memory_Annotation_Tracker_Node, memory_tracker.first); } pthread_mutex_unlock(&memory_tracker_mutex); @@ -923,4 +927,4 @@ font_make_face_sig(){ return(result); } -//////////////////////////////// \ No newline at end of file +////////////////////////////////