library/src/memory_profiling/BP_LibraryMemoryProfiling.cc
// disables the memory profiler subsystem and resets/frees memory.
disables the memory profiler subsystem and resets/frees memory.
disables the memory profiler subsystem and resets / frees memory .
BP_ERROR_T BP_ShutdownMemProfilerSubsystem()
{
#if DEBUG_MEMORY_PROFILER == 1
	printf("\n [!!] Preparing to disable memory profiler..");
#endif
	sem_wait(&global_memory_profiler_semaphore);
	if(global_memory_profiler_enabled != 0xcafebabe)
		return ERR_FAILURE;
	global_memory_profiler_enabled = 0;
	if(global_memprof_pool_n)
	for(size_t j = 0; j < global_memprof_pool_n; j++)
	{
		if(global_memprof_pool[j].mark)
			free(global_memprof_pool[j].mark);
	}
	if(global_memprof_pool)
		free(global_memprof_pool);
	global_memprof_pool                    = NULL;
	global_memprof_pool_n                  = 0;
	global_memprof_last_index_added        = 0;
	global_memprofiler_pool_memory_usage   = 0;
	global_size_for_chunk_logging          = 0;
	sem_post(&global_memory_profiler_semaphore);
#if DEBUG_MEMORY_PROFILER == 1
	printf("\n [!!] Memory profiler has been disabled.");
#endif
	return ERR_SUCCESS;
}
BP_ERROR_T BP_ShutdownMemProfilerSubsystem ( ) { #if DEBUG_MEMORY_PROFILER == 1 printf ( " \n " ) ; #endif sem_wait ( & global_memory_profiler_semaphore ) ; if ( global_memory_profiler_enabled != 0xcafebabe ) return ERR_FAILURE ; global_memory_profiler_enabled = 0 ; if ( global_memprof_pool_n ) for ( size_t j = 0 ; j < global_memprof_pool_n ; j ++ ) { if ( global_memprof_pool [ j ] . mark ) free ( global_memprof_pool [ j ] . mark ) ; } if ( global_memprof_pool ) free ( global_memprof_pool ) ; global_memprof_pool = NULL ; global_memprof_pool_n = 0 ; global_memprof_last_index_added = 0 ; global_memprofiler_pool_memory_usage = 0 ; global_size_for_chunk_logging = 0 ; sem_post ( & global_memory_profiler_semaphore ) ; #if DEBUG_MEMORY_PROFILER == 1 printf ( " \n " ) ; #endif return ERR_SUCCESS ; }
disables the memory profiler subsystem and resets/frees memory.
disables the memory profiler subsystem and resets / frees memory .
// lock global semaphor // set flag indicating capability is disabled // free marks if necessary // reset all the global vars // unlock global semaphore // return indicating success