result_t prf_initmgr() { result_t r; /* samples */ g_prf.samples_back = prf_create_samples(); g_prf.samples_front = prf_create_samples(); if (g_prf.samples_back == NULL || g_prf.samples_front == NULL) return RET_FAIL; mt_mutex_init(&g_prf.samples_mtx); /* web server */ r = webserver_init(eng_get_params()->dev.webserver_port); if (IS_FAIL(r)) return RET_FAIL; /* commands */ r = arr_create(mem_heap(), &g_prf.cmds, sizeof(struct prf_cmd_desc), 20, 20, MID_PRF); if (IS_FAIL(r)) return RET_OUTOFMEMORY; /* register commands */ prf_register_cmd("mem-heap", prf_cmd_heapinfo); prf_register_cmd("mem-heap-sub", prf_cmd_heapsubinfo); prf_register_cmd("mem-gpu", prf_cmd_gpumem); prf_register_cmd("prf-gantt", prf_cmd_profilergantt); prf_register_cmd("mem-buffers", prf_cmd_buffersmem); prf_register_cmd("info-cam", prf_cmd_getcaminfo); MT_ATOMIC_SET(g_prf.init, TRUE); return RET_OK; }
result_t mem_init(int trace_mem) { if (g_mem != NULL) return RET_FAIL; g_mem = (struct mem_mgr*)malloc(sizeof(struct mem_mgr)); if (g_mem == NULL) return RET_OUTOFMEMORY; memset(g_mem, 0x00, sizeof(struct mem_mgr)); /* initialize default allocators */ g_memheap.alloc_fn = heap_alloc; g_memheap.free_fn = heap_free; g_memheap.alignedalloc_fn = heap_alignedalloc; g_memheap.alignedfree_fn = heap_alignedfree; g_memheap.realloc_fn = heap_realloc; g_memheap.alignedrealloc_fn = heap_alignedrealloc; g_memheap.save_fn = NULL; g_memheap.load_fn = NULL; g_mem->trace = trace_mem; mt_mutex_init(&g_mem->lock); g_mem->ids = (struct memid_desc*)malloc(sizeof(struct memid_desc)*16); if (g_mem->ids == NULL) return RET_OUTOFMEMORY; g_mem->id_cnt_max = 16; return RET_OK; }