MCPcopy Create free account
hub / github.com/defold/defold / InitializeLibrary

Function InitializeLibrary

engine/dlib/src/dlib/memprofile.cpp:267–302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265 }
266
267 void InitializeLibrary(dmMemProfile::InternalData* internal_data)
268 {
269 Log(STDERR_FILENO, "dmMemProfile loaded\n");
270
271 pthread_mutexattr_t attr;
272 int ret = pthread_mutexattr_init(&attr);
273 assert(ret == 0);
274 ret = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
275 assert(ret == 0);
276
277 g_Mutex = new pthread_mutex_t;
278 ret = pthread_mutex_init(g_Mutex, &attr);
279 assert(ret == 0);
280 ret = pthread_mutexattr_destroy(&attr);
281 assert(ret == 0);
282
283 *internal_data->m_IsEnabled = true;
284 g_ExtStats = internal_data->m_Stats;
285
286 if (m_PropertyRegisterGroup)
287 {
288 g_ProfileGroup = m_PropertyRegisterGroup("Memory", "", 0);
289 g_ProfileAllocations = m_PropertyRegisterU32("Allocations", "Num allocations", 0, 0, GetProfileGroup);
290 g_ProfileAmount = m_PropertyRegisterU32("Amount", "Total amount (bytes)", 0, 0, GetProfileGroup);
291 }
292
293 char* trace = getenv("DMMEMPROFILE_TRACE");
294 if (trace && strlen(trace) > 0 && trace[0] != '0')
295 {
296 g_TraceFile = open("memprofile.trace", O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
297 if (g_TraceFile == -1)
298 {
299 Log(STDERR_FILENO, "WARNING: Unable to open memprofile.trace\n");
300 }
301 }
302 }
303
304 void FinalizeLibrary()
305 {

Callers 1

Calls 3

getenvFunction · 0.85
LogFunction · 0.70
assertFunction · 0.50

Tested by

no test coverage detected