mirror of
https://github.com/X11Libre/xf86-input-mouse.git
synced 2026-03-24 09:34:07 +00:00
Replace libc wrappers to xcalloc and friends with libc calls.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Tested-by: Alan Coopersmith <alan.coopersmith@oracle.com>
This commit is contained in:
@@ -468,7 +468,7 @@ wsconsPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
|
||||
xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
|
||||
else {
|
||||
xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name);
|
||||
xfree(pMse);
|
||||
free(pMse);
|
||||
pInfo->private = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
@@ -545,7 +545,7 @@ usbMouseProc(DeviceIntPtr pPointer, int what)
|
||||
else {
|
||||
pMse->buffer = XisbNew(pInfo->fd, pUsbMse->packetSize);
|
||||
if (!pMse->buffer) {
|
||||
xfree(pMse);
|
||||
free(pMse);
|
||||
xf86CloseSerial(pInfo->fd);
|
||||
pInfo->fd = -1;
|
||||
} else {
|
||||
@@ -566,7 +566,7 @@ usbMouseProc(DeviceIntPtr pPointer, int what)
|
||||
if (pInfo->fd != -1) {
|
||||
RemoveEnabledDevice(pInfo->fd);
|
||||
if (pUsbMse->packetSize > 8 && pUsbMse->buffer) {
|
||||
xfree(pUsbMse->buffer);
|
||||
free(pUsbMse->buffer);
|
||||
}
|
||||
if (pMse->buffer) {
|
||||
XisbFree(pMse->buffer);
|
||||
@@ -642,10 +642,10 @@ usbPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
|
||||
report_desc_t reportDesc;
|
||||
int i;
|
||||
|
||||
pUsbMse = xalloc(sizeof(UsbMseRec));
|
||||
pUsbMse = malloc(sizeof(UsbMseRec));
|
||||
if (pUsbMse == NULL) {
|
||||
xf86Msg(X_ERROR, "%s: cannot allocate UsbMouseRec\n", pInfo->name);
|
||||
xfree(pMse);
|
||||
free(pMse);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -663,8 +663,8 @@ usbPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
|
||||
xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
|
||||
else {
|
||||
xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name);
|
||||
xfree(pUsbMse);
|
||||
xfree(pMse);
|
||||
free(pUsbMse);
|
||||
free(pMse);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -687,12 +687,12 @@ usbPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
|
||||
if (pUsbMse->packetSize <= 8) {
|
||||
pUsbMse->buffer = pMse->protoBuf;
|
||||
} else {
|
||||
pUsbMse->buffer = xalloc(pUsbMse->packetSize);
|
||||
pUsbMse->buffer = malloc(pUsbMse->packetSize);
|
||||
}
|
||||
if (pUsbMse->buffer == NULL) {
|
||||
xf86Msg(X_ERROR, "%s: cannot allocate buffer\n", pInfo->name);
|
||||
xfree(pUsbMse);
|
||||
xfree(pMse);
|
||||
free(pUsbMse);
|
||||
free(pMse);
|
||||
xf86CloseSerial(pInfo->fd);
|
||||
return FALSE;
|
||||
}
|
||||
@@ -773,7 +773,7 @@ xf86OSMouseInit(int flags)
|
||||
{
|
||||
OSMouseInfoPtr p;
|
||||
|
||||
p = xcalloc(sizeof(OSMouseInfoRec), 1);
|
||||
p = calloc(sizeof(OSMouseInfoRec), 1);
|
||||
if (!p)
|
||||
return NULL;
|
||||
p->SupportedInterfaces = SupportedInterfaces;
|
||||
|
||||
@@ -154,7 +154,7 @@ OsMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags)
|
||||
xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
|
||||
else {
|
||||
xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name);
|
||||
xfree(pMse);
|
||||
free(pMse);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -231,7 +231,7 @@ xf86OSMouseInit(int flags)
|
||||
{
|
||||
OSMouseInfoPtr p;
|
||||
|
||||
p = xcalloc(sizeof(OSMouseInfoRec), 1);
|
||||
p = calloc(sizeof(OSMouseInfoRec), 1);
|
||||
if (!p)
|
||||
return NULL;
|
||||
p->SupportedInterfaces = SupportedInterfaces;
|
||||
|
||||
@@ -122,7 +122,7 @@ lnxMouseMagic(InputInfoPtr pInfo)
|
||||
#ifdef DEBUG
|
||||
ErrorF("readlink failed for %s (%s)\n", dev, strerror(errno));
|
||||
#endif
|
||||
xfree(realdev);
|
||||
free(realdev);
|
||||
return NULL;
|
||||
}
|
||||
realdev[i] = '\0';
|
||||
@@ -135,7 +135,7 @@ lnxMouseMagic(InputInfoPtr pInfo)
|
||||
if (!strchr(realdev, '/')) {
|
||||
char *tmp = xnfalloc(strlen(realdev) + 5 + 1);
|
||||
sprintf(tmp, "/dev/%s", realdev);
|
||||
xfree(realdev);
|
||||
free(realdev);
|
||||
realdev = tmp;
|
||||
}
|
||||
}
|
||||
@@ -148,7 +148,7 @@ lnxMouseMagic(InputInfoPtr pInfo)
|
||||
proto = MOUSE_PROTO_MSC;
|
||||
else if (strcmp(realdev, DEFAULT_GPM_CTL_DEV) == 0)
|
||||
proto = MOUSE_PROTO_GPM;
|
||||
xfree(realdev);
|
||||
free(realdev);
|
||||
/*
|
||||
* If the protocol can't be guessed from the device name,
|
||||
* try to characterise it.
|
||||
@@ -209,7 +209,7 @@ xf86OSMouseInit(int flags)
|
||||
{
|
||||
OSMouseInfoPtr p;
|
||||
|
||||
p = xcalloc(sizeof(OSMouseInfoRec), 1);
|
||||
p = calloc(sizeof(OSMouseInfoRec), 1);
|
||||
if (!p)
|
||||
return NULL;
|
||||
p->SupportedInterfaces = SupportedInterfaces;
|
||||
|
||||
40
src/mouse.c
40
src/mouse.c
@@ -337,7 +337,7 @@ MouseCommonOptions(InputInfoPtr pInfo)
|
||||
|
||||
|
||||
if (pMse->pDragLock)
|
||||
xfree(pMse->pDragLock);
|
||||
free(pMse->pDragLock);
|
||||
pMse->pDragLock = NULL;
|
||||
|
||||
s = xf86SetStrOption(pInfo->options, "DragLockButtons", NULL);
|
||||
@@ -350,7 +350,7 @@ MouseCommonOptions(InputInfoPtr pInfo)
|
||||
char *s1; /* parse input string */
|
||||
DragLockPtr pLock;
|
||||
|
||||
pLock = pMse->pDragLock = xcalloc(1, sizeof(DragLockRec));
|
||||
pLock = pMse->pDragLock = calloc(1, sizeof(DragLockRec));
|
||||
/* init code */
|
||||
|
||||
/* initial string to be taken apart */
|
||||
@@ -441,7 +441,7 @@ MouseCommonOptions(InputInfoPtr pInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
xfree(s);
|
||||
free(s);
|
||||
}
|
||||
|
||||
s = xf86SetStrOption(pInfo->options, "ZAxisMapping", "4 5");
|
||||
@@ -468,7 +468,7 @@ MouseCommonOptions(InputInfoPtr pInfo)
|
||||
if (b3 > 0 && b3 <= MSE_MAXBUTTONS &&
|
||||
b4 > 0 && b4 <= MSE_MAXBUTTONS) {
|
||||
if (msg)
|
||||
xfree(msg);
|
||||
free(msg);
|
||||
msg = xstrdup("buttons XX, YY, ZZ and WW");
|
||||
if (msg)
|
||||
sprintf(msg, "buttons %d, %d, %d and %d", b1, b2, b3, b4);
|
||||
@@ -482,12 +482,12 @@ MouseCommonOptions(InputInfoPtr pInfo)
|
||||
}
|
||||
if (msg) {
|
||||
xf86Msg(X_CONFIG, "%s: ZAxisMapping: %s\n", pInfo->name, msg);
|
||||
xfree(msg);
|
||||
free(msg);
|
||||
} else {
|
||||
xf86Msg(X_WARNING, "%s: Invalid ZAxisMapping value: \"%s\"\n",
|
||||
pInfo->name, s);
|
||||
}
|
||||
xfree(s);
|
||||
free(s);
|
||||
}
|
||||
if (xf86SetBoolOption(pInfo->options, "EmulateWheel", FALSE)) {
|
||||
Bool yFromConfig = FALSE;
|
||||
@@ -541,9 +541,9 @@ MouseCommonOptions(InputInfoPtr pInfo)
|
||||
}
|
||||
if (msg) {
|
||||
xf86Msg(X_CONFIG, "%s: XAxisMapping: %s\n", pInfo->name, msg);
|
||||
xfree(msg);
|
||||
free(msg);
|
||||
}
|
||||
xfree(s);
|
||||
free(s);
|
||||
}
|
||||
s = xf86SetStrOption(pInfo->options, "YAxisMapping", NULL);
|
||||
if (s) {
|
||||
@@ -567,9 +567,9 @@ MouseCommonOptions(InputInfoPtr pInfo)
|
||||
}
|
||||
if (msg) {
|
||||
xf86Msg(X_CONFIG, "%s: YAxisMapping: %s\n", pInfo->name, msg);
|
||||
xfree(msg);
|
||||
free(msg);
|
||||
}
|
||||
xfree(s);
|
||||
free(s);
|
||||
}
|
||||
if (!yFromConfig) {
|
||||
pMse->negativeY = 4;
|
||||
@@ -602,7 +602,7 @@ MouseCommonOptions(InputInfoPtr pInfo)
|
||||
pMse->buttonMap[n++] = 1 << (b-1);
|
||||
if (b > pMse->buttons) pMse->buttons = b;
|
||||
}
|
||||
xfree(s);
|
||||
free(s);
|
||||
}
|
||||
/* get maximum of mapped buttons */
|
||||
for (i = pMse->buttons-1; i >= 0; i--) {
|
||||
@@ -638,9 +638,9 @@ MouseCommonOptions(InputInfoPtr pInfo)
|
||||
}
|
||||
if (msg) {
|
||||
xf86Msg(X_CONFIG, "%s: DoubleClickButtons: %s\n", pInfo->name, msg);
|
||||
xfree(msg);
|
||||
free(msg);
|
||||
}
|
||||
xfree(s);
|
||||
free(s);
|
||||
}
|
||||
}
|
||||
/*
|
||||
@@ -898,7 +898,7 @@ MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
|
||||
* XXX This should be done by a function in the core server since the
|
||||
* MouseDevRec is defined in the os-support layer.
|
||||
*/
|
||||
if (!(pMse = xcalloc(sizeof(MouseDevRec), 1)))
|
||||
if (!(pMse = calloc(sizeof(MouseDevRec), 1)))
|
||||
return pInfo;
|
||||
pInfo->private = pMse;
|
||||
pMse->Ctrl = MouseCtrl;
|
||||
@@ -1011,8 +1011,8 @@ MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
|
||||
else {
|
||||
xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name);
|
||||
if (pMse->mousePriv)
|
||||
xfree(pMse->mousePriv);
|
||||
xfree(pMse);
|
||||
free(pMse->mousePriv);
|
||||
free(pMse);
|
||||
pInfo->private = NULL;
|
||||
return pInfo;
|
||||
}
|
||||
@@ -1020,7 +1020,7 @@ MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
|
||||
xf86CloseSerial(pInfo->fd);
|
||||
pInfo->fd = -1;
|
||||
|
||||
if (!(mPriv = (pointer) xcalloc(sizeof(mousePrivRec), 1)))
|
||||
if (!(mPriv = (pointer) calloc(sizeof(mousePrivRec), 1)))
|
||||
return pInfo;
|
||||
pMse->mousePriv = mPriv;
|
||||
pMse->CommonOptions(pInfo);
|
||||
@@ -1711,7 +1711,7 @@ MouseProc(DeviceIntPtr device, int what)
|
||||
device->public.on = FALSE;
|
||||
break;
|
||||
case DEVICE_CLOSE:
|
||||
xfree(pMse->mousePriv);
|
||||
free(pMse->mousePriv);
|
||||
pMse->mousePriv = NULL;
|
||||
break;
|
||||
}
|
||||
@@ -3149,7 +3149,7 @@ createProtoList(MouseDevPtr pMse, MouseProtocolID *protoList)
|
||||
blocked = xf86BlockSIGIO ();
|
||||
|
||||
/* create a private copy first so we can write in the old list */
|
||||
if ((tmplist = xalloc(sizeof(MouseProtocolID) * NUM_AUTOPROBE_PROTOS))){
|
||||
if ((tmplist = malloc(sizeof(MouseProtocolID) * NUM_AUTOPROBE_PROTOS))){
|
||||
for (i = 0; protoList[i] != PROT_UNKNOWN; i++) {
|
||||
tmplist[i] = protoList[i];
|
||||
}
|
||||
@@ -3259,7 +3259,7 @@ createProtoList(MouseDevPtr pMse, MouseProtocolID *protoList)
|
||||
|
||||
mPriv->protoList[k] = PROT_UNKNOWN;
|
||||
|
||||
xfree(tmplist);
|
||||
free(tmplist);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -205,10 +205,10 @@ vuidPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
|
||||
VuidMsePtr pVuidMse;
|
||||
int buttons, i;
|
||||
|
||||
pVuidMse = xcalloc(sizeof(VuidMseRec), 1);
|
||||
pVuidMse = calloc(sizeof(VuidMseRec), 1);
|
||||
if (pVuidMse == NULL) {
|
||||
xf86Msg(X_ERROR, "%s: cannot allocate VuidMouseRec\n", pInfo->name);
|
||||
xfree(pMse);
|
||||
free(pMse);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -229,9 +229,9 @@ vuidPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
|
||||
xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
|
||||
} else {
|
||||
xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name);
|
||||
xfree(pVuidMse->strmod);
|
||||
xfree(pVuidMse);
|
||||
xfree(pMse);
|
||||
free(pVuidMse->strmod);
|
||||
free(pVuidMse);
|
||||
free(pMse);
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
@@ -247,9 +247,9 @@ vuidPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
|
||||
pInfo->name, pVuidMse->strmod, strerror(errno));
|
||||
xf86CloseSerial(pInfo->fd);
|
||||
pInfo->fd = -1;
|
||||
xfree(pVuidMse->strmod);
|
||||
xfree(pVuidMse);
|
||||
xfree(pMse);
|
||||
free(pVuidMse->strmod);
|
||||
free(pVuidMse);
|
||||
free(pMse);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -586,7 +586,7 @@ vuidMouseProc(DeviceIntPtr pPointer, int what)
|
||||
xf86Msg(X_WARNING, "%s: cannot push module '%s' "
|
||||
"onto mouse device: %s\n", pInfo->name,
|
||||
pVuidMse->strmod, strerror(errno));
|
||||
xfree(pVuidMse->strmod);
|
||||
free(pVuidMse->strmod);
|
||||
pVuidMse->strmod = NULL;
|
||||
}
|
||||
}
|
||||
@@ -795,7 +795,7 @@ xf86OSMouseInit(int flags)
|
||||
{
|
||||
OSMouseInfoPtr p;
|
||||
|
||||
p = xcalloc(sizeof(OSMouseInfoRec), 1);
|
||||
p = calloc(sizeof(OSMouseInfoRec), 1);
|
||||
if (!p)
|
||||
return NULL;
|
||||
p->SupportedInterfaces = SupportedInterfaces;
|
||||
|
||||
Reference in New Issue
Block a user