Xi: only alloc memory for feedback classes if it doesn't already exist.
This commit is contained in:
		
							parent
							
								
									4eb87c8693
								
							
						
					
					
						commit
						52fc7aed18
					
				| 
						 | 
				
			
			@ -224,8 +224,16 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to)
 | 
			
		|||
        KbdFeedbackPtr *k, it;
 | 
			
		||||
        k = &to->kbdfeed;
 | 
			
		||||
        for(it = from->kbdfeed; it; it = it->next)
 | 
			
		||||
        {
 | 
			
		||||
            if (!(*k))
 | 
			
		||||
            {
 | 
			
		||||
                *k = xcalloc(1, sizeof(KbdFeedbackClassRec));
 | 
			
		||||
                if (!*k)
 | 
			
		||||
                {
 | 
			
		||||
                    ErrorF("[Xi] Cannot alloc memory for class copy.");
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            (*k)->BellProc = it->BellProc;
 | 
			
		||||
            (*k)->CtrlProc = it->CtrlProc;
 | 
			
		||||
            (*k)->ctrl     = it->ctrl;
 | 
			
		||||
| 
						 | 
				
			
			@ -240,8 +248,16 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to)
 | 
			
		|||
        PtrFeedbackPtr *p, it;
 | 
			
		||||
        p = &to->ptrfeed;
 | 
			
		||||
        for (it = from->ptrfeed; it; it = it->next)
 | 
			
		||||
        {
 | 
			
		||||
            if (!(*p))
 | 
			
		||||
            {
 | 
			
		||||
                *p = xcalloc(1, sizeof(PtrFeedbackClassRec));
 | 
			
		||||
                if (!*p)
 | 
			
		||||
                {
 | 
			
		||||
                    ErrorF("[Xi] Cannot alloc memory for class copy.");
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            (*p)->CtrlProc = it->CtrlProc;
 | 
			
		||||
            (*p)->ctrl     = it->ctrl;
 | 
			
		||||
            /* XXX: xkb_sli needs to be copied */
 | 
			
		||||
| 
						 | 
				
			
			@ -255,8 +271,16 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to)
 | 
			
		|||
        IntegerFeedbackPtr *i, it;
 | 
			
		||||
        i = &to->intfeed;
 | 
			
		||||
        for (it = from->intfeed; it; it = it->next)
 | 
			
		||||
        {
 | 
			
		||||
            if (!(*i))
 | 
			
		||||
            {
 | 
			
		||||
                *i = xcalloc(1, sizeof(IntegerFeedbackClassRec));
 | 
			
		||||
                if (!(*i))
 | 
			
		||||
                {
 | 
			
		||||
                    ErrorF("[Xi] Cannot alloc memory for class copy.");
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            (*i)->CtrlProc = it->CtrlProc;
 | 
			
		||||
            (*i)->ctrl     = it->ctrl;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -269,8 +293,16 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to)
 | 
			
		|||
        StringFeedbackPtr *s, it;
 | 
			
		||||
        s = &to->stringfeed;
 | 
			
		||||
        for (it = from->stringfeed; it; it = it->next)
 | 
			
		||||
        {
 | 
			
		||||
            if (!(*s))
 | 
			
		||||
            {
 | 
			
		||||
                *s = xcalloc(1, sizeof(StringFeedbackClassRec));
 | 
			
		||||
                if (!(*s))
 | 
			
		||||
                {
 | 
			
		||||
                    ErrorF("[Xi] Cannot alloc memory for class copy.");
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            (*s)->CtrlProc = it->CtrlProc;
 | 
			
		||||
            (*s)->ctrl     = it->ctrl;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -283,8 +315,16 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to)
 | 
			
		|||
        BellFeedbackPtr *b, it;
 | 
			
		||||
        b = &to->bell;
 | 
			
		||||
        for (it = from->bell; it; it = it->next)
 | 
			
		||||
        {
 | 
			
		||||
            if (!(*b))
 | 
			
		||||
            {
 | 
			
		||||
                *b = xcalloc(1, sizeof(BellFeedbackClassRec));
 | 
			
		||||
                if (!(*b))
 | 
			
		||||
                {
 | 
			
		||||
                    ErrorF("[Xi] Cannot alloc memory for class copy.");
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            (*b)->BellProc = it->BellProc;
 | 
			
		||||
            (*b)->CtrlProc = it->CtrlProc;
 | 
			
		||||
            (*b)->ctrl     = it->ctrl;
 | 
			
		||||
| 
						 | 
				
			
			@ -298,8 +338,16 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to)
 | 
			
		|||
        LedFeedbackPtr *l, it;
 | 
			
		||||
        l = &to->leds;
 | 
			
		||||
        for (it = from->leds; it; it = it->next)
 | 
			
		||||
        {
 | 
			
		||||
            if (!(*l))
 | 
			
		||||
            {
 | 
			
		||||
                *l = xcalloc(1, sizeof(LedFeedbackClassRec));
 | 
			
		||||
                if (!(*l))
 | 
			
		||||
                {
 | 
			
		||||
                    ErrorF("[Xi] Cannot alloc memory for class copy.");
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            (*l)->CtrlProc = it->CtrlProc;
 | 
			
		||||
            (*l)->ctrl     = it->ctrl;
 | 
			
		||||
            /* XXX: xkb_sli needs to be copied */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue