void memory_context_thread_deallocate( void ) { memory_context_t* context = get_thread_memory_context(); if( context ) memory_deallocate( context ); set_thread_memory_context( 0 ); }
void memory_context_push( uint16_t context_id ) { memory_context_t* context = get_thread_memory_context(); if( !context ) { context = memory_allocate_zero( sizeof( memory_context_t ), 0, MEMORY_PERSISTENT ); set_thread_memory_context( context ); } FOUNDATION_ASSERT_MSG( context->depth < BUILD_SIZE_MEMORY_CONTEXT_DEPTH, "Memory context stack overflow" ); context->context[ context->depth ] = context_id; if( context->depth < BUILD_SIZE_MEMORY_CONTEXT_DEPTH-1 ) ++context->depth; }
void memory_context_push(hash_t context_id) { memory_context_t* context = get_thread_memory_context(); if (!context) { context = memory_allocate(0, sizeof(memory_context_t) + (sizeof(hash_t) * _foundation_config.memory_context_depth), 0, MEMORY_PERSISTENT | MEMORY_ZERO_INITIALIZED); set_thread_memory_context(context); } context->context[ context->depth ] = context_id; if (context->depth < (_foundation_config.memory_context_depth - 1)) ++context->depth; }