Split up memory for devices configured in the config file.
If we're using a continuous block here, we segfault when a device removal triggers an xfree call.
This commit is contained in:
parent
b141b85c25
commit
93ca526892
|
@ -442,7 +442,7 @@ xf86InputDriverlistFromConfig()
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
char **modulearray;
|
char **modulearray;
|
||||||
IDevPtr idp;
|
IDevPtr* idp;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* make sure the config file has been parsed and that we have a
|
* make sure the config file has been parsed and that we have a
|
||||||
|
@ -460,7 +460,7 @@ xf86InputDriverlistFromConfig()
|
||||||
*/
|
*/
|
||||||
if (xf86ConfigLayout.inputs) {
|
if (xf86ConfigLayout.inputs) {
|
||||||
idp = xf86ConfigLayout.inputs;
|
idp = xf86ConfigLayout.inputs;
|
||||||
while (idp->identifier) {
|
while (*idp) {
|
||||||
count++;
|
count++;
|
||||||
idp++;
|
idp++;
|
||||||
}
|
}
|
||||||
|
@ -475,8 +475,8 @@ xf86InputDriverlistFromConfig()
|
||||||
modulearray = xnfalloc((count + 1) * sizeof(char*));
|
modulearray = xnfalloc((count + 1) * sizeof(char*));
|
||||||
count = 0;
|
count = 0;
|
||||||
idp = xf86ConfigLayout.inputs;
|
idp = xf86ConfigLayout.inputs;
|
||||||
while (idp->identifier) {
|
while (idp && *idp) {
|
||||||
modulearray[count] = idp->driver;
|
modulearray[count] = (*idp)->driver;
|
||||||
count++;
|
count++;
|
||||||
idp++;
|
idp++;
|
||||||
}
|
}
|
||||||
|
@ -1185,7 +1185,8 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
|
||||||
IDevPtr corePointer = NULL, coreKeyboard = NULL;
|
IDevPtr corePointer = NULL, coreKeyboard = NULL;
|
||||||
Bool foundPointer = FALSE, foundKeyboard = FALSE;
|
Bool foundPointer = FALSE, foundKeyboard = FALSE;
|
||||||
const char *pointerMsg = NULL, *keyboardMsg = NULL;
|
const char *pointerMsg = NULL, *keyboardMsg = NULL;
|
||||||
IDevPtr indp, i;
|
IDevPtr *devs, /* iterator */
|
||||||
|
indp;
|
||||||
IDevRec Pointer, Keyboard;
|
IDevRec Pointer, Keyboard;
|
||||||
XF86ConfInputPtr confInput;
|
XF86ConfInputPtr confInput;
|
||||||
XF86ConfInputRec defPtr, defKbd;
|
XF86ConfInputRec defPtr, defKbd;
|
||||||
|
@ -1198,7 +1199,8 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
|
||||||
* in the active ServerLayout. If more than one is specified for either,
|
* in the active ServerLayout. If more than one is specified for either,
|
||||||
* remove the core attribute from the later ones.
|
* remove the core attribute from the later ones.
|
||||||
*/
|
*/
|
||||||
for (indp = servlayoutp->inputs; indp->identifier; indp++) {
|
for (devs = servlayoutp->inputs; devs && *devs; devs++) {
|
||||||
|
indp = *devs;
|
||||||
pointer opt1 = NULL, opt2 = NULL;
|
pointer opt1 = NULL, opt2 = NULL;
|
||||||
if (indp->commonOptions &&
|
if (indp->commonOptions &&
|
||||||
xf86CheckBoolOption(indp->commonOptions, "CorePointer", FALSE)) {
|
xf86CheckBoolOption(indp->commonOptions, "CorePointer", FALSE)) {
|
||||||
|
@ -1263,11 +1265,15 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
|
||||||
* removed.
|
* removed.
|
||||||
*/
|
*/
|
||||||
if (corePointer) {
|
if (corePointer) {
|
||||||
for (indp = servlayoutp->inputs; indp->identifier; indp++)
|
for (devs = servlayoutp->inputs; devs && *devs; devs++)
|
||||||
if (indp == corePointer)
|
if (*devs == corePointer)
|
||||||
|
{
|
||||||
|
xfree(*devs);
|
||||||
|
*devs = (IDevPtr)0x1; /* ensure we dont skip next loop*/
|
||||||
break;
|
break;
|
||||||
for (; indp->identifier; indp++)
|
}
|
||||||
indp[0] = indp[1];
|
for (; devs && *devs; devs++)
|
||||||
|
devs[0] = devs[1];
|
||||||
count--;
|
count--;
|
||||||
}
|
}
|
||||||
corePointer = NULL;
|
corePointer = NULL;
|
||||||
|
@ -1327,13 +1333,14 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
|
||||||
foundPointer = configInput(&Pointer, confInput, from);
|
foundPointer = configInput(&Pointer, confInput, from);
|
||||||
if (foundPointer) {
|
if (foundPointer) {
|
||||||
count++;
|
count++;
|
||||||
indp = xnfrealloc(servlayoutp->inputs,
|
devs = xnfrealloc(servlayoutp->inputs,
|
||||||
(count + 1) * sizeof(IDevRec));
|
(count + 1) * sizeof(IDevPtr));
|
||||||
indp[count - 1] = Pointer;
|
devs[count - 1] = xnfalloc(sizeof(IDevRec));
|
||||||
indp[count - 1].extraOptions =
|
*devs[count - 1] = Pointer;
|
||||||
|
devs[count - 1]->extraOptions =
|
||||||
xf86addNewOption(NULL, xnfstrdup("CorePointer"), NULL);
|
xf86addNewOption(NULL, xnfstrdup("CorePointer"), NULL);
|
||||||
indp[count].identifier = NULL;
|
devs[count]->identifier = NULL;
|
||||||
servlayoutp->inputs = indp;
|
servlayoutp->inputs = devs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1351,9 +1358,9 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
|
||||||
* If you're using an evdev keyboard and expect a default mouse
|
* If you're using an evdev keyboard and expect a default mouse
|
||||||
* section ... deal.
|
* section ... deal.
|
||||||
*/
|
*/
|
||||||
for (i = servlayoutp->inputs; i->identifier && i->driver; i++) {
|
for (devs = servlayoutp->inputs; devs && *devs; devs++) {
|
||||||
if (!strcmp(i->driver, "void") || !strcmp(i->driver, "mouse") ||
|
if (!strcmp((*devs)->driver, "void") || !strcmp((*devs)->driver, "mouse") ||
|
||||||
!strcmp(i->driver, "vmmouse") || !strcmp(i->driver, "evdev")) {
|
!strcmp((*devs)->driver, "vmmouse") || !strcmp((*devs)->driver, "evdev")) {
|
||||||
found = 1; break;
|
found = 1; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1366,13 +1373,14 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
|
||||||
foundPointer = configInput(&Pointer, confInput, from);
|
foundPointer = configInput(&Pointer, confInput, from);
|
||||||
if (foundPointer) {
|
if (foundPointer) {
|
||||||
count++;
|
count++;
|
||||||
indp = xnfrealloc(servlayoutp->inputs,
|
devs = xnfrealloc(servlayoutp->inputs,
|
||||||
(count + 1) * sizeof(IDevRec));
|
(count + 1) * sizeof(IDevPtr));
|
||||||
indp[count - 1] = Pointer;
|
devs[count - 1] = xnfalloc(sizeof(IDevRec));
|
||||||
indp[count - 1].extraOptions =
|
*devs[count - 1] = Pointer;
|
||||||
|
devs[count - 1]->extraOptions =
|
||||||
xf86addNewOption(NULL, xnfstrdup("AlwaysCore"), NULL);
|
xf86addNewOption(NULL, xnfstrdup("AlwaysCore"), NULL);
|
||||||
indp[count].identifier = NULL;
|
devs[count]->identifier = NULL;
|
||||||
servlayoutp->inputs = indp;
|
servlayoutp->inputs = devs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1393,11 +1401,15 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
|
||||||
* removed.
|
* removed.
|
||||||
*/
|
*/
|
||||||
if (coreKeyboard) {
|
if (coreKeyboard) {
|
||||||
for (indp = servlayoutp->inputs; indp->identifier; indp++)
|
for (devs = servlayoutp->inputs; devs && *devs; devs++)
|
||||||
if (indp == coreKeyboard)
|
if (*devs == coreKeyboard)
|
||||||
|
{
|
||||||
|
xfree(*devs);
|
||||||
|
*devs = (IDevPtr)0x1; /* ensure we dont skip next loop */
|
||||||
break;
|
break;
|
||||||
for (; indp->identifier; indp++)
|
}
|
||||||
indp[0] = indp[1];
|
for (; devs && *devs; devs++)
|
||||||
|
devs[0] = devs[1];
|
||||||
count--;
|
count--;
|
||||||
}
|
}
|
||||||
coreKeyboard = NULL;
|
coreKeyboard = NULL;
|
||||||
|
@ -1457,13 +1469,14 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
|
||||||
foundKeyboard = configInput(&Keyboard, confInput, from);
|
foundKeyboard = configInput(&Keyboard, confInput, from);
|
||||||
if (foundKeyboard) {
|
if (foundKeyboard) {
|
||||||
count++;
|
count++;
|
||||||
indp = xnfrealloc(servlayoutp->inputs,
|
devs = xnfrealloc(servlayoutp->inputs,
|
||||||
(count + 1) * sizeof(IDevRec));
|
(count + 1) * sizeof(IDevPtr));
|
||||||
indp[count - 1] = Keyboard;
|
devs[count - 1] = xnfalloc(sizeof(IDevRec));
|
||||||
indp[count - 1].extraOptions =
|
*devs[count - 1] = Keyboard;
|
||||||
|
devs[count - 1]->extraOptions =
|
||||||
xf86addNewOption(NULL, xnfstrdup("CoreKeyboard"), NULL);
|
xf86addNewOption(NULL, xnfstrdup("CoreKeyboard"), NULL);
|
||||||
indp[count].identifier = NULL;
|
devs[count]->identifier = NULL;
|
||||||
servlayoutp->inputs = indp;
|
servlayoutp->inputs = devs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1519,7 +1532,7 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
|
||||||
MessageType from;
|
MessageType from;
|
||||||
screenLayoutPtr slp;
|
screenLayoutPtr slp;
|
||||||
GDevPtr gdp;
|
GDevPtr gdp;
|
||||||
IDevPtr indp;
|
IDevPtr* indp;
|
||||||
int i = 0, j;
|
int i = 0, j;
|
||||||
|
|
||||||
if (!servlayoutp)
|
if (!servlayoutp)
|
||||||
|
@ -1731,16 +1744,19 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
|
||||||
ErrorF("Found %d input devices in the layout section %s",
|
ErrorF("Found %d input devices in the layout section %s",
|
||||||
count, conf_layout->lay_identifier);
|
count, conf_layout->lay_identifier);
|
||||||
#endif
|
#endif
|
||||||
indp = xnfalloc((count + 1) * sizeof(IDevRec));
|
indp = xnfcalloc((count + 1), sizeof(IDevPtr));
|
||||||
indp[count].identifier = NULL;
|
indp[count] = NULL;
|
||||||
irp = conf_layout->lay_input_lst;
|
irp = conf_layout->lay_input_lst;
|
||||||
count = 0;
|
count = 0;
|
||||||
while (irp) {
|
while (irp) {
|
||||||
if (!configInput(&indp[count], irp->iref_inputdev, X_CONFIG)) {
|
indp[count] = xnfalloc(sizeof(IDevRec));
|
||||||
xfree(indp);
|
if (!configInput(indp[count], irp->iref_inputdev, X_CONFIG)) {
|
||||||
return FALSE;
|
while(count--)
|
||||||
|
xfree(indp[count]);
|
||||||
|
xfree(indp);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
indp[count].extraOptions = irp->iref_option_lst;
|
indp[count]->extraOptions = irp->iref_option_lst;
|
||||||
count++;
|
count++;
|
||||||
irp = (XF86ConfInputrefPtr)irp->list.next;
|
irp = (XF86ConfInputrefPtr)irp->list.next;
|
||||||
}
|
}
|
||||||
|
@ -1764,7 +1780,7 @@ configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen)
|
||||||
MessageType from;
|
MessageType from;
|
||||||
XF86ConfScreenPtr s;
|
XF86ConfScreenPtr s;
|
||||||
screenLayoutPtr slp;
|
screenLayoutPtr slp;
|
||||||
IDevPtr indp;
|
IDevPtr *indp;
|
||||||
|
|
||||||
if (!servlayoutp)
|
if (!servlayoutp)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1806,8 +1822,8 @@ configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen)
|
||||||
servlayoutp->inactives = xnfcalloc(1, sizeof(GDevRec));
|
servlayoutp->inactives = xnfcalloc(1, sizeof(GDevRec));
|
||||||
servlayoutp->options = NULL;
|
servlayoutp->options = NULL;
|
||||||
/* Set up an empty input device list, then look for some core devices. */
|
/* Set up an empty input device list, then look for some core devices. */
|
||||||
indp = xnfalloc(sizeof(IDevRec));
|
indp = xnfalloc(sizeof(IDevPtr));
|
||||||
indp->identifier = NULL;
|
*indp = NULL;
|
||||||
servlayoutp->inputs = indp;
|
servlayoutp->inputs = indp;
|
||||||
if (!xf86Info.allowEmptyInput && !checkCoreInputDevices(servlayoutp, TRUE))
|
if (!xf86Info.allowEmptyInput && !checkCoreInputDevices(servlayoutp, TRUE))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -981,7 +981,7 @@ InitInput(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
char **argv;
|
char **argv;
|
||||||
{
|
{
|
||||||
IDevPtr pDev;
|
IDevPtr* pDev;
|
||||||
InputDriverPtr pDrv;
|
InputDriverPtr pDrv;
|
||||||
InputInfoPtr pInfo;
|
InputInfoPtr pInfo;
|
||||||
|
|
||||||
|
@ -990,9 +990,9 @@ InitInput(argc, argv)
|
||||||
|
|
||||||
if (serverGeneration == 1) {
|
if (serverGeneration == 1) {
|
||||||
/* Call the PreInit function for each input device instance. */
|
/* Call the PreInit function for each input device instance. */
|
||||||
for (pDev = xf86ConfigLayout.inputs; pDev && pDev->identifier; pDev++) {
|
for (pDev = xf86ConfigLayout.inputs; pDev && *pDev; pDev++) {
|
||||||
if ((pDrv = xf86LookupInputDriver(pDev->driver)) == NULL) {
|
if ((pDrv = xf86LookupInputDriver((*pDev)->driver)) == NULL) {
|
||||||
xf86Msg(X_ERROR, "No Input driver matching `%s'\n", pDev->driver);
|
xf86Msg(X_ERROR, "No Input driver matching `%s'\n", (*pDev)->driver);
|
||||||
/* XXX For now, just continue. */
|
/* XXX For now, just continue. */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1002,14 +1002,14 @@ InitInput(argc, argv)
|
||||||
pDrv->driverName);
|
pDrv->driverName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pInfo = pDrv->PreInit(pDrv, pDev, 0);
|
pInfo = pDrv->PreInit(pDrv, *pDev, 0);
|
||||||
if (!pInfo) {
|
if (!pInfo) {
|
||||||
xf86Msg(X_ERROR, "PreInit returned NULL for \"%s\"\n",
|
xf86Msg(X_ERROR, "PreInit returned NULL for \"%s\"\n",
|
||||||
pDev->identifier);
|
(*pDev)->identifier);
|
||||||
continue;
|
continue;
|
||||||
} else if (!(pInfo->flags & XI86_CONFIGURED)) {
|
} else if (!(pInfo->flags & XI86_CONFIGURED)) {
|
||||||
xf86Msg(X_ERROR, "PreInit failed for input device \"%s\"\n",
|
xf86Msg(X_ERROR, "PreInit failed for input device \"%s\"\n",
|
||||||
pDev->identifier);
|
(*pDev)->identifier);
|
||||||
xf86DeleteInput(pInfo, 0);
|
xf86DeleteInput(pInfo, 0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -526,7 +526,7 @@ typedef struct _serverlayoutrec {
|
||||||
char * id;
|
char * id;
|
||||||
screenLayoutPtr screens;
|
screenLayoutPtr screens;
|
||||||
GDevPtr inactives;
|
GDevPtr inactives;
|
||||||
IDevPtr inputs;
|
IDevPtr* inputs; /* NULL terminated */
|
||||||
pointer options;
|
pointer options;
|
||||||
} serverLayoutRec, *serverLayoutPtr;
|
} serverLayoutRec, *serverLayoutPtr;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user