Exemple #1
0
static void AddMemInfoItem(void *ptr, size_t size, const char *file, int line)
{
	int i;

	for (i = 0; i < XS_MEM_DEBUG_ITEM_MAX; i++)
	{
		if (g_xsMemDebugInfo[i].ptr == NULL || g_xsMemDebugInfo[i].ptr == ptr)
		{
			size_t len = xsStrLen(file);

			g_xsMemAllocSize += size;
			g_xsMemAllocPeak = XS_MAX(g_xsMemAllocPeak, g_xsMemAllocSize);

			g_xsMemDebugInfo[i].ptr = ptr;
			g_xsMemDebugInfo[i].size = size;

			if (len > sizeof(g_xsMemDebugInfo[i].file) - 1)
				file = file + (len - sizeof(g_xsMemDebugInfo[i].file)) + 1;
			
			xsStrCpy(g_xsMemDebugInfo[i].file, file);
			g_xsMemDebugInfo[i].line = line;

			return;
		}
	}

	xsAssert("Memory debug info FULL", file, line);
}
void XSColor_SetHSLA( XSColorRef object, XSFloat h, XSFloat s, XSFloat l, XSFloat a )
{
    if( object == NULL )
    {
        return;
    }
    
    XSRecursiveLock_Lock( object->lock );
    
    object->h = XS_MAX( XS_MIN( h, ( XSFloat )1 ), ( XSFloat )0 );
    object->s = XS_MAX( XS_MIN( s, ( XSFloat )1 ), ( XSFloat )0 );
    object->l = XS_MAX( XS_MIN( l, ( XSFloat )1 ), ( XSFloat )0 );
    object->a = XS_MAX( XS_MIN( a, ( XSFloat )1 ), ( XSFloat )0 );
    
    __XSColor_ConvertFromHSL( object );
    
    XSRecursiveLock_Unlock( object->lock );
}