Xi: only alloc memory for feedback classes if it doesn't already exist.
This commit is contained in:
		
							parent
							
								
									4eb87c8693
								
							
						
					
					
						commit
						52fc7aed18
					
				| 
						 | 
					@ -225,7 +225,15 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to)
 | 
				
			||||||
        k = &to->kbdfeed;
 | 
					        k = &to->kbdfeed;
 | 
				
			||||||
        for(it = from->kbdfeed; it; it = it->next)
 | 
					        for(it = from->kbdfeed; it; it = it->next)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            *k = xcalloc(1, sizeof(KbdFeedbackClassRec));
 | 
					            if (!(*k))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                *k = xcalloc(1, sizeof(KbdFeedbackClassRec));
 | 
				
			||||||
 | 
					                if (!*k)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ErrorF("[Xi] Cannot alloc memory for class copy.");
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            (*k)->BellProc = it->BellProc;
 | 
					            (*k)->BellProc = it->BellProc;
 | 
				
			||||||
            (*k)->CtrlProc = it->CtrlProc;
 | 
					            (*k)->CtrlProc = it->CtrlProc;
 | 
				
			||||||
            (*k)->ctrl     = it->ctrl;
 | 
					            (*k)->ctrl     = it->ctrl;
 | 
				
			||||||
| 
						 | 
					@ -241,7 +249,15 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to)
 | 
				
			||||||
        p = &to->ptrfeed;
 | 
					        p = &to->ptrfeed;
 | 
				
			||||||
        for (it = from->ptrfeed; it; it = it->next)
 | 
					        for (it = from->ptrfeed; it; it = it->next)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            *p = xcalloc(1, sizeof(PtrFeedbackClassRec));
 | 
					            if (!(*p))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                *p = xcalloc(1, sizeof(PtrFeedbackClassRec));
 | 
				
			||||||
 | 
					                if (!*p)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ErrorF("[Xi] Cannot alloc memory for class copy.");
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            (*p)->CtrlProc = it->CtrlProc;
 | 
					            (*p)->CtrlProc = it->CtrlProc;
 | 
				
			||||||
            (*p)->ctrl     = it->ctrl;
 | 
					            (*p)->ctrl     = it->ctrl;
 | 
				
			||||||
            /* XXX: xkb_sli needs to be copied */
 | 
					            /* XXX: xkb_sli needs to be copied */
 | 
				
			||||||
| 
						 | 
					@ -256,7 +272,15 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to)
 | 
				
			||||||
        i = &to->intfeed;
 | 
					        i = &to->intfeed;
 | 
				
			||||||
        for (it = from->intfeed; it; it = it->next)
 | 
					        for (it = from->intfeed; it; it = it->next)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            *i = xcalloc(1, sizeof(IntegerFeedbackClassRec));
 | 
					            if (!(*i))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                *i = xcalloc(1, sizeof(IntegerFeedbackClassRec));
 | 
				
			||||||
 | 
					                if (!(*i))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ErrorF("[Xi] Cannot alloc memory for class copy.");
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            (*i)->CtrlProc = it->CtrlProc;
 | 
					            (*i)->CtrlProc = it->CtrlProc;
 | 
				
			||||||
            (*i)->ctrl     = it->ctrl;
 | 
					            (*i)->ctrl     = it->ctrl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -270,7 +294,15 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to)
 | 
				
			||||||
        s = &to->stringfeed;
 | 
					        s = &to->stringfeed;
 | 
				
			||||||
        for (it = from->stringfeed; it; it = it->next)
 | 
					        for (it = from->stringfeed; it; it = it->next)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            *s = xcalloc(1, sizeof(StringFeedbackClassRec));
 | 
					            if (!(*s))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                *s = xcalloc(1, sizeof(StringFeedbackClassRec));
 | 
				
			||||||
 | 
					                if (!(*s))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ErrorF("[Xi] Cannot alloc memory for class copy.");
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            (*s)->CtrlProc = it->CtrlProc;
 | 
					            (*s)->CtrlProc = it->CtrlProc;
 | 
				
			||||||
            (*s)->ctrl     = it->ctrl;
 | 
					            (*s)->ctrl     = it->ctrl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -284,7 +316,15 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to)
 | 
				
			||||||
        b = &to->bell;
 | 
					        b = &to->bell;
 | 
				
			||||||
        for (it = from->bell; it; it = it->next)
 | 
					        for (it = from->bell; it; it = it->next)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            *b = xcalloc(1, sizeof(BellFeedbackClassRec));
 | 
					            if (!(*b))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                *b = xcalloc(1, sizeof(BellFeedbackClassRec));
 | 
				
			||||||
 | 
					                if (!(*b))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ErrorF("[Xi] Cannot alloc memory for class copy.");
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            (*b)->BellProc = it->BellProc;
 | 
					            (*b)->BellProc = it->BellProc;
 | 
				
			||||||
            (*b)->CtrlProc = it->CtrlProc;
 | 
					            (*b)->CtrlProc = it->CtrlProc;
 | 
				
			||||||
            (*b)->ctrl     = it->ctrl;
 | 
					            (*b)->ctrl     = it->ctrl;
 | 
				
			||||||
| 
						 | 
					@ -299,7 +339,15 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to)
 | 
				
			||||||
        l = &to->leds;
 | 
					        l = &to->leds;
 | 
				
			||||||
        for (it = from->leds; it; it = it->next)
 | 
					        for (it = from->leds; it; it = it->next)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            *l = xcalloc(1, sizeof(LedFeedbackClassRec));
 | 
					            if (!(*l))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                *l = xcalloc(1, sizeof(LedFeedbackClassRec));
 | 
				
			||||||
 | 
					                if (!(*l))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ErrorF("[Xi] Cannot alloc memory for class copy.");
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            (*l)->CtrlProc = it->CtrlProc;
 | 
					            (*l)->CtrlProc = it->CtrlProc;
 | 
				
			||||||
            (*l)->ctrl     = it->ctrl;
 | 
					            (*l)->ctrl     = it->ctrl;
 | 
				
			||||||
            /* XXX: xkb_sli needs to be copied */
 | 
					            /* XXX: xkb_sli needs to be copied */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue