@@ -10,6 +10,7 @@ static inline void free_stack_lock(struct SwiftNetMemoryAllocatorStack* const st
1010 atomic_store_explicit (& stack -> owner , ALLOCATOR_STACK_FREE , memory_order_release );
1111}
1212
13+ #ifdef SWIFT_NET_INTERNAL_TESTING
1314static inline void unlock_ptr_status (struct SwiftNetMemoryAllocatorStack * const stack ) {
1415 atomic_store_explicit (& stack -> accessing_ptr_status , false, memory_order_release );
1516}
@@ -27,6 +28,7 @@ static inline void lock_ptr_status(struct SwiftNetMemoryAllocatorStack* const st
2728 target = false;
2829 }
2930}
31+ #endif
3032
3133struct SwiftNetMemoryAllocatorStack * const find_free_pointer_stack (const struct SwiftNetMemoryAllocator * const allocator ) {
3234 for (struct SwiftNetMemoryAllocatorStack * current_stack = atomic_load (& allocator -> data .first_item ); current_stack != NULL ; current_stack = atomic_load_explicit (& current_stack -> next , memory_order_acquire )) {
@@ -111,7 +113,7 @@ struct SwiftNetMemoryAllocator allocator_create(const uint32_t item_size, const
111113
112114 atomic_store_explicit (& new_allocator .creating_stack , STACK_CREATING_UNLOCKED , memory_order_release );
113115
114- #ifdef SWIFT_NET_DEBUG
116+ #ifdef SWIFT_NET_INTERNAL_TESTING
115117 atomic_store_explicit (& first_stack -> accessing_ptr_status , false, memory_order_release );
116118 first_stack -> ptr_status = calloc (sizeof (uint8_t ), (chunk_item_amount / 8 ) + 1 );
117119 #endif
@@ -157,7 +159,7 @@ static void create_new_stack(struct SwiftNetMemoryAllocator* const memory_alloca
157159 ((void * * )allocated_memory_pointers )[i ] = (uint8_t * )allocated_memory + (i * item_size );
158160 }
159161
160- #ifdef SWIFT_NET_DEBUG
162+ #ifdef SWIFT_NET_INTERNAL_TESTING
161163 atomic_store_explicit (& stack -> accessing_ptr_status , false, memory_order_release );
162164 stack -> ptr_status = calloc (sizeof (uint8_t ), (chunk_item_amount / 8 ) + 1 );
163165 #endif
@@ -183,7 +185,7 @@ void* allocator_allocate(struct SwiftNetMemoryAllocator* const memory_allocator)
183185
184186 void * item_ptr = * ptr_to_data ;
185187
186- #ifdef SWIFT_NET_DEBUG
188+ #ifdef SWIFT_NET_INTERNAL_TESTING
187189 const uint32_t offset = item_ptr - valid_stack -> data ;
188190 const uint32_t index = offset / memory_allocator -> item_size ;
189191
@@ -202,7 +204,7 @@ void* allocator_allocate(struct SwiftNetMemoryAllocator* const memory_allocator)
202204 return item_ptr ;
203205}
204206
205- #ifdef SWIFT_NET_DEBUG
207+ #ifdef SWIFT_NET_INTERNAL_TESTING
206208 static inline bool is_already_free (struct SwiftNetMemoryAllocator * const memory_allocator , void * const memory_location ) {
207209 for (struct SwiftNetMemoryAllocatorStack * stack = atomic_load_explicit (& memory_allocator -> data .first_item , memory_order_acquire ); stack != NULL ; stack = atomic_load_explicit (& stack -> next , memory_order_acquire )) {
208210 if (
@@ -235,7 +237,7 @@ void* allocator_allocate(struct SwiftNetMemoryAllocator* const memory_allocator)
235237#endif
236238
237239void allocator_free (struct SwiftNetMemoryAllocator * const memory_allocator , void * const memory_location ) {
238- #ifdef SWIFT_NET_DEBUG
240+ #ifdef SWIFT_NET_INTERNAL_TESTING
239241 const bool already_free = is_already_free (memory_allocator , memory_location );
240242
241243 if (already_free == true) {
@@ -257,7 +259,7 @@ void allocator_free(struct SwiftNetMemoryAllocator* const memory_allocator, void
257259
258260 ((void * * )free_stack -> pointers )[size ] = memory_location ;
259261
260- #ifdef SWIFT_NET_DEBUG
262+ #ifdef SWIFT_NET_INTERNAL_TESTING
261263 const uint32_t offset = memory_location - free_stack -> data ;
262264 const uint32_t index = offset / memory_allocator -> item_size ;
263265
@@ -286,7 +288,7 @@ void allocator_destroy(struct SwiftNetMemoryAllocator* const memory_allocator) {
286288 break ;
287289 }
288290
289- #ifdef SWIFT_NET_DEBUG
291+ #ifdef SWIFT_NET_INTERNAL_TESTING
290292 lock_ptr_status (current_stack );
291293
292294 const uint32_t total_items = memory_allocator -> chunk_item_amount ;
0 commit comments