library/src/memory_profiling/BP_LibraryMemoryProfiling.cc
// Mark an allocation if it exists.
Mark an allocation if it exists.
Mark an allocation if it exists .
BP_ERROR_T BP_MemProfilerMarkChunkByAddr(void * chunk, char * mark)
{
	if(!chunk || !mark)
		return ERR_FAILURE;
#if DEBUG_MEMORY_PROFILER == 1
	printf("\n [!!] Attempting to mark chunk: %p with %s", chunk, mark);
#endif
	P_BP_MEMPROF_ENTRY entry = BP_MemProfilerFindChunk(chunk);
	if(!entry)
		return ERR_FAILURE;
	size_t mark_len = bpstrlen(mark);
	if(mark_len >= 4096)
		return ERR_FAILURE;
	entry->mark = strdup(mark);
#if DEBUG_MEMORY_PROFILER == 1
	printf("\n [!!] Marked chunk %p OK!", chunk);
#endif
	return ERR_SUCCESS;
}
BP_ERROR_T BP_MemProfilerMarkChunkByAddr ( void * chunk , char * mark ) { if ( ! chunk || ! mark ) return ERR_FAILURE ; #if DEBUG_MEMORY_PROFILER == 1 printf ( " \n " , chunk , mark ) ; #endif P_BP_MEMPROF_ENTRY entry = BP_MemProfilerFindChunk ( chunk ) ; if ( ! entry ) return ERR_FAILURE ; size_t mark_len = bpstrlen ( mark ) ; if ( mark_len >= 4096 ) return ERR_FAILURE ; entry -> mark = strdup ( mark ) ; #if DEBUG_MEMORY_PROFILER == 1 printf ( " \n " , chunk ) ; #endif return ERR_SUCCESS ; }
Mark an allocation if it exists.
Mark an allocation if it exists .
// ensure we have some parameter validation // look up the entry // Dont mark chunks with long strings, stupid.  You'll just exhaust // your memory. // set the mark here after length validation // return indicating success