示例#1
0
json_t prf_cmd_profilergantt(const char* param1, const char* param2)
{
    PROTECT_CMD();

    /* protect front buffer during data creation */
    mt_mutex_lock(&g_prf.samples_mtx);
    struct prf_samples* s = (struct prf_samples*)g_prf.samples_front;

    json_t root = json_create_obj();
    json_t data = json_create_obj();
    json_additem_toobj(root, "data", data);

    json_t jsamples = json_create_arr();
    json_additem_toobj(data, "duration", json_create_num(s->duration));
    json_additem_toobj(data, "samples", jsamples);

    struct linked_list* l = s->nodes;
    while (l != NULL)   {
        prf_create_node_json(jsamples, (struct prf_node*)l->data);
        l = l->next;
    }

    mt_mutex_unlock(&g_prf.samples_mtx);
    return root;
}
示例#2
0
void* mem_realloc(void *p, size_t size, const char *source, uint line, uint id)
{
    ASSERT(g_mem);

    void* ptr;
    if (g_mem->trace)     {
        mt_mutex_lock(&g_mem->lock);
        if (g_mem->stats.limit_bytes != 0 &&
            (size + g_mem->stats.alloc_bytes) > g_mem->stats.limit_bytes)
        {
            return NULL;
        }

        ptr = mem_realloc_withtrace(p, size);
        if (ptr != NULL)    {
            struct mem_trace_data* trace = get_trace_data(ptr);
#if defined(_DEBUG_)
            path_getfullfilename(trace->filename, source);
            trace->line = line;
#endif
            trace->size = size;
            trace->mem_id = id;

            mem_addto_ids(id, size);
        }
        mt_mutex_unlock(&g_mem->lock);
    }	else	{
        ptr = malloc_withsize(size);
    }
    return ptr;
}
示例#3
0
void mem_free(void* ptr)
{
    ASSERT(g_mem);
	if (g_mem->trace)	{
		mt_mutex_lock(&g_mem->lock);
        mem_removefrom_ids(ptr);
		mem_free_withtrace(ptr);
		mt_mutex_unlock(&g_mem->lock);
	}	else	{
		free_withsize(ptr);
	}
}