Exemplo n.º 1
0
void * gim_realloc(void *ptr, size_t oldsize, size_t newsize)
{
 	void * newptr = gim_alloc(newsize);
    size_t copysize = oldsize<newsize?oldsize:newsize;
    gim_simd_memcpy(newptr,ptr,copysize);
    gim_free(ptr);
    return newptr;
}
Exemplo n.º 2
0
void GIM_DYNARRAY_DESTROY(GDYNAMIC_ARRAY & array_data)
{
    if(array_data.m_pdata != 0)
    {
        gim_free(array_data.m_pdata,0);
        array_data.m_reserve_size = 0;
        array_data.m_size = 0;
        array_data.m_pdata = 0;
    }
}
Exemplo n.º 3
0
void * gim_realloc(void *ptr, size_t oldsize, size_t newsize)
{
  /*if (g_reallocfn) return g_reallocfn(ptr,oldsize,newsize);
  else return realloc(ptr,newsize);*/
  //return realloc(ptr,newsize);
  void * newptr = gim_alloc(newsize);
  size_t copysize = newsize> oldsize? oldsize: newsize;
  memcpy(newptr,ptr,copysize);
  gim_free(ptr,oldsize);
  return newptr;
}
void gim_merge_contacts(GDYNAMIC_ARRAY * source_contacts,
					GDYNAMIC_ARRAY * dest_contacts)
{
    dest_contacts->m_size = 0;

	GUINT32 source_count = source_contacts->m_size;
	GIM_CONTACT * psource_contacts	= GIM_DYNARRAY_POINTER(GIM_CONTACT,(*source_contacts));
	//create keys
	GIM_RSORT_TOKEN * keycontacts = (GIM_RSORT_TOKEN * )gim_alloc(sizeof(GIM_RSORT_TOKEN)*source_count);

    GUINT32 i;
	for(i=0;i<source_count;i++)
	{
		keycontacts[i].m_value = i;
		GIM_CALC_KEY_CONTACT(psource_contacts[i].m_point,keycontacts[i].m_key);
	}

	//sort keys
	GIM_QUICK_SORT_ARRAY(GIM_RSORT_TOKEN , keycontacts, source_count, RSORT_TOKEN_COMPARATOR,GIM_DEF_EXCHANGE_MACRO);

	// Merge contacts
	GIM_CONTACT * pcontact = 0;
	GIM_CONTACT * scontact = 0;
	GUINT32 key,last_key=0;

	for(i=0;i<source_contacts->m_size;i++)
	{
	    key = keycontacts[i].m_key;
		scontact = &psource_contacts[keycontacts[i].m_value];

		if(i>0 && last_key ==  key)
		{
			//merge contact
			if(pcontact->m_depth > scontact->m_depth + CONTACT_DIFF_EPSILON)
			{
			    GIM_COPY_CONTACTS(pcontact, scontact);
			}
		}
		else
		{//add new contact
		    GIM_DYNARRAY_PUSH_EMPTY(GIM_CONTACT,(*dest_contacts));
            pcontact = GIM_DYNARRAY_POINTER_LAST(GIM_CONTACT,(*dest_contacts));
		    GIM_COPY_CONTACTS(pcontact, scontact);
        }
		last_key = key;
	}
	gim_free(keycontacts,0);
}
Exemplo n.º 5
0
static void _system_buffer_free_function(GPTR buffer_handle,GUINT32 size)
{
    gim_free(buffer_handle,size);
}
Exemplo n.º 6
0
void _system_buffer_free_function(GUINT buffer_handle,GUINT size)
{
    gim_free((void*)buffer_handle,size);
}