Remove more superfluous if(p) checks around free(p)

This patch has been generated by the following Coccinelle semantic patch:

@@
expression E;
@@

-if(E) { free(E); }
+free(E);

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Fernando Carrijo <fcarrijo@yahoo.com.br>
Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
Mikhail Gusarov 2010-06-06 15:28:30 +07:00
parent 5a0fc0ad21
commit 0a4d8cbdcd
84 changed files with 240 additions and 412 deletions

View File

@ -1276,8 +1276,7 @@ XineramaGetImageData(
}
if(ScratchMem)
free(ScratchMem);
free(ScratchMem);
RegionUninit(&SrcRegion);
RegionUninit(&GrabRegion);

View File

@ -604,7 +604,7 @@ bailout:
if (removeAuth)
RemoveAuthorization(stuff->nbytesAuthProto, protoname,
authdata_len, pAuthdata);
if (pAuth) free(pAuth);
free(pAuth);
return err;
} /* ProcSecurityGenerateAuthorization */

View File

@ -323,7 +323,7 @@ XaceCensorImage(
*/
memset(pBuf, 0, (int)(widthBytesLine * h));
}
if (pRects) free(pRects);
free(pRects);
if (pScratchGC) FreeScratchGC(pScratchGC);
if (pPix) FreeScratchPixmapHeader(pPix);
}

View File

@ -259,8 +259,7 @@ ProcXvMCCreateContext(ClientPtr client)
WriteToClient(client, dwords << 2, (char*)data);
AddResource(pContext->context_id, XvMCRTContext, pContext);
if(data)
free(data);
free(data);
return Success;
}
@ -327,8 +326,7 @@ ProcXvMCCreateSurface(ClientPtr client)
WriteToClient(client, dwords << 2, (char*)data);
AddResource(pSurface->surface_id, XvMCRTSurface, pSurface);
if(data)
free(data);
free(data);
pContext->refcnt++;
@ -444,8 +442,7 @@ ProcXvMCCreateSubpicture(ClientPtr client)
WriteToClient(client, dwords << 2, (char*)data);
AddResource(pSubpicture->subpicture_id, XvMCRTSubpicture, pSubpicture);
if(data)
free(data);
free(data);
pContext->refcnt++;

View File

@ -153,8 +153,7 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
}
WriteToClient(client, length * 4, (char *)coords);
}
if (coords)
free(coords);
free(coords);
return Success;
}

View File

@ -622,8 +622,7 @@ XIFetchDeviceProperty(DeviceIntPtr dev, Atom property)
static void
XIDestroyDeviceProperty (XIPropertyPtr prop)
{
if (prop->value.data)
free(prop->value.data);
free(prop->value.data);
free(prop);
}
@ -798,8 +797,7 @@ XIChangeDeviceProperty (DeviceIntPtr dev, Atom property, Atom type,
&new_value, checkonly);
if (checkonly && rc != Success)
{
if (new_value.data)
free(new_value.data);
free(new_value.data);
return (rc);
}
}
@ -808,8 +806,7 @@ XIChangeDeviceProperty (DeviceIntPtr dev, Atom property, Atom type,
checkonly = !checkonly;
} while (!checkonly);
}
if (prop_value->data)
free(prop_value->data);
free(prop_value->data);
*prop_value = new_value;
} else if (len == 0)
{

View File

@ -184,10 +184,8 @@ unwind:
while (options) {
tmpo = options;
options = options->next;
if (tmpo->key)
free(tmpo->key);
if (tmpo->value)
free(tmpo->value);
free(tmpo->key);
free(tmpo->value);
free(tmpo);
}

View File

@ -251,28 +251,23 @@ device_added(LibHalContext *hal_ctx, const char *udi)
{
if (!strcasecmp(&tmp[3], "layout"))
{
if (xkb_opts.layout)
free(xkb_opts.layout);
free(xkb_opts.layout);
xkb_opts.layout = strdup(tmp_val);
} else if (!strcasecmp(&tmp[3], "model"))
{
if (xkb_opts.model)
free(xkb_opts.model);
free(xkb_opts.model);
xkb_opts.model = strdup(tmp_val);
} else if (!strcasecmp(&tmp[3], "rules"))
{
if (xkb_opts.rules)
free(xkb_opts.rules);
free(xkb_opts.rules);
xkb_opts.rules = strdup(tmp_val);
} else if (!strcasecmp(&tmp[3], "variant"))
{
if (xkb_opts.variant)
free(xkb_opts.variant);
free(xkb_opts.variant);
xkb_opts.variant = strdup(tmp_val);
} else if (!strcasecmp(&tmp[3], "options"))
{
if (xkb_opts.options)
free(xkb_opts.options);
free(xkb_opts.options);
xkb_opts.options = strdup(tmp_val);
}
} else
@ -289,8 +284,7 @@ device_added(LibHalContext *hal_ctx, const char *udi)
(!strcasecmp(&tmp[3], "options")) &&
(tmp_val = get_prop_string_array(hal_ctx, udi, psi_key)))
{
if (xkb_opts.options)
free(xkb_opts.options);
free(xkb_opts.options);
xkb_opts.options = strdup(tmp_val);
}
}
@ -366,22 +360,17 @@ device_added(LibHalContext *hal_ctx, const char *udi)
}
for (; dev; dev = dev->next){
if (dev->config_info)
free(dev->config_info);
free(dev->config_info);
dev->config_info = xstrdup(config_info);
}
unwind:
if (set)
libhal_free_property_set(set);
if (path)
free(path);
if (driver)
free(driver);
if (name)
free(name);
if (config_info)
free(config_info);
free(path);
free(driver);
free(name);
free(config_info);
while (!dev && (tmpo = options)) {
options = tmpo->next;
free(tmpo->key);
@ -401,16 +390,11 @@ unwind:
free(attrs.tags);
}
if (xkb_opts.layout)
free(xkb_opts.layout);
if (xkb_opts.rules)
free(xkb_opts.rules);
if (xkb_opts.model)
free(xkb_opts.model);
if (xkb_opts.variant)
free(xkb_opts.variant);
if (xkb_opts.options)
free(xkb_opts.options);
free(xkb_opts.layout);
free(xkb_opts.rules);
free(xkb_opts.model);
free(xkb_opts.variant);
free(xkb_opts.options);
dbus_error_free(&error);

View File

@ -693,10 +693,7 @@ ProcDbeGetVisualInfo(ClientPtr client)
if (!(pScrVisInfo = (XdbeScreenVisualInfo *)malloc(count *
sizeof(XdbeScreenVisualInfo))))
{
if (pDrawables)
{
free(pDrawables);
}
free(pDrawables);
return(BadAlloc);
}
@ -722,10 +719,7 @@ ProcDbeGetVisualInfo(ClientPtr client)
}
/* Free pDrawables if we needed to allocate it above. */
if (pDrawables)
{
free(pDrawables);
}
free(pDrawables);
return (rc == Success) ? BadAlloc : rc;
}
@ -803,10 +797,7 @@ ProcDbeGetVisualInfo(ClientPtr client)
}
free(pScrVisInfo);
if (pDrawables)
{
free(pDrawables);
}
free(pDrawables);
return Success;

View File

@ -1639,8 +1639,7 @@ AllocColorCells (int client, ColormapPtr pmap, int colors, int planes,
pcr->client = client;
if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (pointer)pcr))
ok = BadAlloc;
} else if (pcr)
free(pcr);
} else free(pcr);
return (ok);
}
@ -1730,8 +1729,7 @@ AllocColorPlanes (int client, ColormapPtr pmap, int colors,
pcr->client = client;
if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (pointer)pcr))
ok = BadAlloc;
} else if (pcr)
free(pcr);
} else free(pcr);
return (ok);
}
@ -1764,9 +1762,9 @@ AllocDirect (int client, ColormapPtr pmap, int c, int r, int g, int b, Bool cont
ppixBlue = malloc(npixB * sizeof(Pixel));
if (!ppixRed || !ppixGreen || !ppixBlue)
{
if (ppixBlue) free(ppixBlue);
if (ppixGreen) free(ppixGreen);
if (ppixRed) free(ppixRed);
free(ppixBlue);
free(ppixGreen);
free(ppixRed);
return(BadAlloc);
}

View File

@ -740,8 +740,7 @@ FreeDeviceClass(int type, pointer *class)
case ButtonClass:
{
ButtonClassPtr *b = (ButtonClassPtr*)class;
if ((*b)->xkb_acts)
free((*b)->xkb_acts);
free((*b)->xkb_acts);
free((*b));
break;
}
@ -749,8 +748,7 @@ FreeDeviceClass(int type, pointer *class)
{
ValuatorClassPtr *v = (ValuatorClassPtr*)class;
if ((*v)->motion)
free((*v)->motion);
free((*v)->motion);
free((*v));
break;
}
@ -1465,10 +1463,8 @@ InitStringFeedbackClassDeviceStruct (
feedc->ctrl.symbols_displayed = malloc(sizeof (KeySym) * max_symbols);
if (!feedc->ctrl.symbols_supported || !feedc->ctrl.symbols_displayed)
{
if (feedc->ctrl.symbols_supported)
free(feedc->ctrl.symbols_supported);
if (feedc->ctrl.symbols_displayed)
free(feedc->ctrl.symbols_displayed);
free(feedc->ctrl.symbols_supported);
free(feedc->ctrl.symbols_displayed);
free(feedc);
return FALSE;
}
@ -2283,8 +2279,7 @@ ProcGetMotionEvents(ClientPtr client)
WriteSwappedDataToClient(client, nEvents * sizeof(xTimecoord),
(char *)coords);
}
if (coords)
free(coords);
free(coords);
return Success;
}

View File

@ -2837,7 +2837,7 @@ ProcQueryColors(ClientPtr client)
return(BadAlloc);
if( (rc = QueryColors(pcmp, count, (Pixel *)&stuff[1], prgbs, client)) )
{
if (prgbs) free(prgbs);
free(prgbs);
return rc;
}
memset(&qcr, 0, sizeof(xQueryColorsReply));
@ -2851,7 +2851,7 @@ ProcQueryColors(ClientPtr client)
client->pSwapReplyFunc = (ReplySwapPtr) SQColorsExtend;
WriteSwappedDataToClient(client, count * sizeof(xrgb), prgbs);
}
if (prgbs) free(prgbs);
free(prgbs);
return Success;
}

View File

@ -677,7 +677,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
return TRUE;
}
if (err == FontNameAlias) {
if (resolved) free(resolved);
free(resolved);
resolved = malloc(resolvedlen + 1);
if (resolved)
memmove(resolved, tmpname, resolvedlen + 1);
@ -731,8 +731,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
{
c->saved = c->current;
c->haveSaved = TRUE;
if (c->savedName)
free(c->savedName);
free(c->savedName);
c->savedName = malloc(namelen + 1);
if (c->savedName)
memmove(c->savedName, name, namelen + 1);
@ -828,10 +827,10 @@ bail:
for (i = 0; i < c->num_fpes; i++)
FreeFPE(c->fpe_list[i]);
free(c->fpe_list);
if (c->savedName) free(c->savedName);
free(c->savedName);
FreeFontNames(names);
free(c);
if (resolved) free(resolved);
free(resolved);
return TRUE;
}
@ -994,8 +993,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
c->saved = c->current;
c->haveSaved = TRUE;
c->savedNumFonts = numFonts;
if (c->savedName)
free(c->savedName);
free(c->savedName);
c->savedName = malloc(namelen + 1);
if (c->savedName)
memmove(c->savedName, name, namelen + 1);
@ -1106,7 +1104,7 @@ bail:
FreeFPE(c->fpe_list[i]);
free(c->reply);
free(c->fpe_list);
if (c->savedName) free(c->savedName);
free(c->savedName);
free(c);
return TRUE;
}

View File

@ -893,7 +893,7 @@ InitCallbackManager(void)
{
DeleteCallbackList(listsToCleanup[i]);
}
if (listsToCleanup) free(listsToCleanup);
free(listsToCleanup);
numCallbackListsToCleanup = 0;
listsToCleanup = NULL;

View File

@ -3793,10 +3793,8 @@ DeliverFocusedEvent(DeviceIntPtr keybd, InternalEvent *event, WindowPtr window)
}
unwind:
if (xE)
free(xE);
if (xi2)
free(xi2);
free(xE);
free(xi2);
return;
}
@ -3976,10 +3974,8 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
}
}
if (xi)
free(xi);
if (xi2)
free(xi2);
free(xi);
free(xi2);
}
/* This function is used to set the key pressed or key released state -

View File

@ -327,8 +327,7 @@ void
AllocateMotionHistory(DeviceIntPtr pDev)
{
int size;
if (pDev->valuator->motion)
free(pDev->valuator->motion);
free(pDev->valuator->motion);
if (pDev->valuator->numMotionEvents < 1)
return;

View File

@ -441,10 +441,10 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab)
details = malloc(i * sizeof(Mask *));
if (!deletes || !adds || !updates || !details)
{
if (details) free(details);
if (updates) free(updates);
if (adds) free(adds);
if (deletes) free(deletes);
free(details);
free(updates);
free(adds);
free(deletes);
return FALSE;
}

View File

@ -762,8 +762,7 @@ RegionOp(
AppendRegions(newReg, r2BandEnd, r2End);
}
if (oldData)
free(oldData);
free(oldData);
if (!(numRects = newReg->data->numRects))
{

View File

@ -257,8 +257,7 @@ exaDestroyPixmap_mixed(PixmapPtr pPixmap)
pExaPixmap->driverPriv = NULL;
if (pExaPixmap->pDamage) {
if (pExaPixmap->sys_ptr)
free(pExaPixmap->sys_ptr);
free(pExaPixmap->sys_ptr);
pExaPixmap->sys_ptr = NULL;
pExaPixmap->pDamage = NULL;
}

View File

@ -2431,8 +2431,7 @@ int __glXDisp_ClientInfo(__GLXclientState *cl, GLbyte *pc)
cl->GLClientmajorVersion = req->major;
cl->GLClientminorVersion = req->minor;
if (cl->GLClientextensions)
free(cl->GLClientextensions);
free(cl->GLClientextensions);
buf = (const char *)(req+1);
cl->GLClientextensions = xstrdup(buf);

View File

@ -205,8 +205,8 @@ GLboolean __glXFreeContext(__GLXcontext *cx)
{
if (cx->idExists || cx->isCurrent) return GL_FALSE;
if (cx->feedbackBuf) free(cx->feedbackBuf);
if (cx->selectBuf) free(cx->selectBuf);
free(cx->feedbackBuf);
free(cx->selectBuf);
if (cx == __glXLastContext) {
__glXFlushContextCache();
}
@ -323,10 +323,10 @@ glxClientCallback (CallbackListPtr *list,
}
}
if (cl->returnBuf) free(cl->returnBuf);
if (cl->largeCmdBuf) free(cl->largeCmdBuf);
if (cl->currentContexts) free(cl->currentContexts);
if (cl->GLClientextensions) free(cl->GLClientextensions);
free(cl->returnBuf);
free(cl->largeCmdBuf);
free(cl->currentContexts);
free(cl->GLClientextensions);
break;
default:

View File

@ -272,10 +272,8 @@ char *__glXcombine_strings(const char *cext_string, const char *sext_string)
s2 = sext_string;
}
if (!combo_string || !s1) {
if (combo_string)
free(combo_string);
if (s1)
free(s1);
free(combo_string);
free(s1);
return NULL;
}
combo_string[0] = '\0';

View File

@ -97,9 +97,7 @@ static int __glXMakeBitmapFromGlyph(FontPtr font, CharInfoPtr pci)
pci->metrics.characterWidth, 0,
allocbuf ? allocbuf : buf) );
if (allocbuf) {
free(allocbuf);
}
free(allocbuf);
return Success;
#undef __GL_CHAR_BUF_SIZE
}

View File

@ -98,7 +98,7 @@ const char *dmxConfigCopyString(const char *string, int length)
void dmxConfigFree(void *area)
{
if (area) free(area);
free(area);
}
DMXConfigTokenPtr dmxConfigCreateToken(int token, int line,
@ -370,7 +370,7 @@ DMXConfigOptionPtr dmxConfigCreateOption(DMXConfigTokenPtr pStart,
void dmxConfigFreeOption(DMXConfigOptionPtr p)
{
if (!p) return;
if (p->string) free(p->string);
free(p->string);
dmxConfigFreeToken(p->start);
dmxConfigFreeString(p->option);
dmxConfigFreeToken(p->end);

View File

@ -351,7 +351,7 @@ do { \
#define MAXSCREENSFREE(o) \
do { \
if (o) free(o); \
free(o); \
o = NULL; \
} while (0)

View File

@ -606,8 +606,8 @@ void InitOutput(ScreenInfo *pScreenInfo, int argc, char *argv[])
dmxScreens[i].stat = NULL;
}
for (i = 0; i < dmxNumInputs; i++) dmxInputFree(&dmxInputs[i]);
if (dmxScreens) free(dmxScreens);
if (dmxInputs) free(dmxInputs);
free(dmxScreens);
free(dmxInputs);
dmxScreens = NULL;
dmxInputs = NULL;
dmxNumScreens = 0;

View File

@ -122,7 +122,7 @@ DMXStatInfo *dmxStatAlloc(void)
/** Free the memory used by a \a DMXStatInfo structure. */
void dmxStatFree(DMXStatInfo *pt)
{
if (pt) free(pt);
free(pt);
}
static void dmxStatValue(DMXStatAvg *data, unsigned long value)

View File

@ -105,7 +105,5 @@ __glXRealloc(void *addr, size_t newSize)
void
__glXFree(void *addr)
{
if (addr) {
free(addr);
}
free(addr);
}

View File

@ -531,8 +531,7 @@ Bool glxInitVisuals(int *nvisualp, VisualPtr *visualp,
__glXFree(pNewVisualConfigs);
/* Free the private list created by DDX HW driver */
if (visualPrivates)
free(visualPrivates);
free(visualPrivates);
visualPrivates = NULL;
return TRUE;

View File

@ -114,7 +114,7 @@ pointer dmxBackendCreatePrivate(DeviceIntPtr pDevice)
* #dmxBackendCreatePrivate. */
void dmxBackendDestroyPrivate(pointer private)
{
if (private) free(private);
free(private);
}
static void *dmxBackendTestScreen(DMXScreenInfo *dmxScreen, void *closure)

View File

@ -148,7 +148,7 @@ pointer dmxConsoleCreatePrivate(DeviceIntPtr pDevice)
/** If \a private is non-NULL, free its associated memory. */
void dmxConsoleDestroyPrivate(pointer private)
{
if (private) free(private);
free(private);
}
static void dmxConsoleDrawFineCursor(myPrivate *priv, XRectangle *rect)

View File

@ -1084,9 +1084,9 @@ static void dmxInputFreeLocal(DMXLocalInputInfoRec *local)
if (local->isCore && local->type == DMX_LOCAL_KEYBOARD)
dmxLocalCoreKeyboard = NULL;
if (local->destroy_private) local->destroy_private(local->private);
if (local->history) free(local->history);
if (local->valuators) free(local->valuators);
if (local->deviceName) free(local->deviceName);
free(local->history);
free(local->valuators);
free(local->deviceName);
local->private = NULL;
local->history = NULL;
local->deviceName = NULL;
@ -1100,9 +1100,9 @@ void dmxInputFree(DMXInputInfo *dmxInput)
if (!dmxInput) return;
if (dmxInput->keycodes) free(dmxInput->keycodes);
if (dmxInput->symbols) free(dmxInput->symbols);
if (dmxInput->geometry) free(dmxInput->geometry);
free(dmxInput->keycodes);
free(dmxInput->symbols);
free(dmxInput->geometry);
for (i = 0; i < dmxInput->numDevs; i++) {
dmxInputFreeLocal(dmxInput->devs[i]);

View File

@ -368,7 +368,7 @@ pointer kbdLinuxCreatePrivate(DeviceIntPtr pKeyboard)
/** Destroy a private structure. */
void kbdLinuxDestroyPrivate(pointer priv)
{
if (priv) free(priv);
free(priv);
}
/** Ring the bell.

View File

@ -301,7 +301,7 @@ pointer msLinuxCreatePrivate(DeviceIntPtr pMouse)
/** Destroy a private structure. */
void msLinuxDestroyPrivate(pointer priv)
{
if (priv) free(priv);
free(priv);
}
/** Fill the \a info structure with information needed to initialize \a

View File

@ -269,7 +269,7 @@ pointer ps2LinuxCreatePrivate(DeviceIntPtr pMouse)
/** Destroy a private structure. */
void ps2LinuxDestroyPrivate(pointer priv)
{
if (priv) free(priv);
free(priv);
}
/** Fill the \a info structure with information needed to initialize \a

View File

@ -377,5 +377,5 @@ pointer usbCreatePrivate(DeviceIntPtr pDevice)
/** Destroy a private structure. */
void usbDestroyPrivate(pointer priv)
{
if (priv) free(priv);
free(priv);
}

View File

@ -168,8 +168,7 @@ fakeMapFramebuffer (KdScreenInfo *screen)
KdSetPointerMatrix (&m);
priv->bytes_per_line = ((screen->width * screen->fb.bitsPerPixel + 31) >> 5) << 2;
if (priv->base)
free (priv->base);
free(priv->base);
priv->base = malloc (priv->bytes_per_line * screen->height);
if (scrpriv->shadow)

View File

@ -120,8 +120,7 @@ FreeList(const char ***list, int *lines)
int i;
for (i = 0; i < *lines; i++) {
if ((*list)[i])
free((*list)[i]);
free((*list)[i]);
}
free(*list);
*list = NULL;

View File

@ -848,10 +848,10 @@ xf86ReconfigureLayout(void)
for (i = 0; i < MAXSCREENS; i++) {
xf86ScreenLayoutPtr sl = &xf86ScreenLayout[i];
/* we don't have to zero these, xf86InitOrigins() takes care of that */
if (sl->left) free(sl->left);
if (sl->right) free(sl->right);
if (sl->up) free(sl->up);
if (sl->down) free(sl->down);
free(sl->left);
free(sl->right);
free(sl->up);
free(sl->down);
}
xf86InitOrigins();

View File

@ -234,8 +234,7 @@ xf86DeleteScreen(int scrnIndex, int flags)
if (pScrn->drv)
pScrn->drv->refCount--;
if (pScrn->privates)
free(pScrn->privates);
free(pScrn->privates);
xf86ClearEntityListForScreen(scrnIndex);
@ -327,8 +326,7 @@ xf86DeleteInput(InputInfoPtr pInp, int flags)
/* This should *really* be handled in drv->UnInit(dev) call instead, but
* if the driver forgets about it make sure we free it or at least crash
* with flying colors */
if (pInp->private)
free(pInp->private);
free(pInp->private);
FreeInputAttributes(pInp->attrs);
@ -2017,8 +2015,7 @@ xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
*/
pNewProp->next = NULL;
} else {
if (pNewProp->name)
free(pNewProp->name);
free(pNewProp->name);
existing = TRUE;
}

View File

@ -844,10 +844,8 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
unwind:
if (is_auto && !xf86Info.autoAddDevices)
xf86Msg(X_INFO, "AutoAddDevices is off - not adding device.\n");
if(idev->driver)
free(idev->driver);
if(idev->identifier)
free(idev->identifier);
free(idev->driver);
free(idev->identifier);
xf86optionListFree(idev->commonOptions);
free(idev);
return rval;

View File

@ -327,7 +327,7 @@ CMapDestroyColormap (ColormapPtr cmap)
CMapLinkPtr prevLink = NULL, pLink = pScreenPriv->maps;
if(pColPriv) {
if(pColPriv->colors) free(pColPriv->colors);
free(pColPriv->colors);
free(pColPriv);
}

View File

@ -478,8 +478,7 @@ xf86MatchSbusInstances(const char *driverName, int sbusDevId,
instances[i].claimed = TRUE;
instances[i].dev = dev;
}
if (promPath)
free(promPath);
free(promPath);
}
DebugF("%s instances found: %d\n", driverName, numClaimedInstances);

View File

@ -1102,8 +1102,7 @@ ProcXF86VidModeValidateModeLine(ClientPtr client)
status = VidModeCheckModeForDriver(stuff->screen, modetmp);
status_reply:
if(modetmp)
free(modetmp);
free(modetmp);
rep.type = X_Reply;
rep.length = bytes_to_int32(SIZEOF(xXF86VidModeValidateModeLineReply)

View File

@ -578,10 +578,8 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
drmInstallSIGIOHandler(pDRIPriv->drmFD, DRISwapContext))) {
DRIDrvMsg(pScreen->myNum, X_ERROR,
"[drm] failed to setup DRM signal handler\n");
if (pDRIPriv->hiddenContextStore)
free(pDRIPriv->hiddenContextStore);
if (pDRIPriv->partial3DContextStore)
free(pDRIPriv->partial3DContextStore);
free(pDRIPriv->hiddenContextStore);
free(pDRIPriv->partial3DContextStore);
DRIDestroyContextPriv(pDRIContextPriv);
return FALSE;
} else {
@ -1618,7 +1616,7 @@ DRICreateInfoRec(void)
void
DRIDestroyInfoRec(DRIInfoPtr DRIInfo)
{
if (DRIInfo->busIdString) free(DRIInfo->busIdString);
free(DRIInfo->busIdString);
free((char*)DRIInfo);
}

View File

@ -378,10 +378,8 @@ tsort(void)
if (n == NULL)
ErrorF("tsort: internal error -- could not find cycle");
}
if (cycle_buf)
free(cycle_buf);
if (longest_cycle)
free(longest_cycle);
free(cycle_buf);
free(longest_cycle);
if (graph)
free_nodes(graph);
}

View File

@ -315,16 +315,14 @@ InitSubdirs(const char **subdirlist)
if (**s == '/' || **s == '\\' || strchr(*s, ':') ||
strstr(*s, "..")) {
xf86Msg(X_ERROR, "InitSubdirs: Bad subdir: \"%s\"\n", *s);
if (tmp_subdirlist)
free(tmp_subdirlist);
free(tmp_subdirlist);
return NULL;
}
}
}
subdirs = malloc((i * 2 + 1) * sizeof(char *));
if (!subdirs) {
if (tmp_subdirlist)
free(tmp_subdirlist);
free(tmp_subdirlist);
return NULL;
}
i = 0;
@ -348,8 +346,7 @@ InitSubdirs(const char **subdirlist)
while (--i >= 0)
free(subdirs[i]);
free(subdirs);
if (tmp_subdirlist)
free(tmp_subdirlist);
free(tmp_subdirlist);
return NULL;
}
/* tack on the OS name */
@ -367,8 +364,7 @@ InitSubdirs(const char **subdirlist)
}
subdirs[i] = NULL;
}
if (tmp_subdirlist)
free(tmp_subdirlist);
free(tmp_subdirlist);
return (const char **)subdirs;
}

View File

@ -157,8 +157,7 @@ xf86CrtcDestroy (xf86CrtcPtr crtc)
xf86_config->num_crtc--;
break;
}
if (crtc->params)
free(crtc->params);
free(crtc->params);
free(crtc->gamma_red);
free(crtc);
}
@ -382,8 +381,7 @@ done:
crtc->transformPresent = saved_transform_present;
}
if (adjusted_mode->name)
free(adjusted_mode->name);
free(adjusted_mode->name);
free(adjusted_mode);
if (didLock)
@ -482,8 +480,7 @@ xf86OutputSetMonitor (xf86OutputPtr output)
if (!output->name)
return;
if (output->options)
free(output->options);
free(output->options);
output->options = xnfalloc (sizeof (xf86OutputOptions));
memcpy (output->options, xf86OutputOptions, sizeof (xf86OutputOptions));

View File

@ -103,8 +103,7 @@ xf86_dga_get_modes (ScreenPtr pScreen)
if (display_mode == scrn->modes)
break;
}
if (xf86_config->dga_modes)
free(xf86_config->dga_modes);
free(xf86_config->dga_modes);
xf86_config->dga_nmode = num;
xf86_config->dga_modes = modes;
return TRUE;

View File

@ -405,8 +405,7 @@ xf86CrtcRotate (xf86CrtcPtr crtc)
*/
xf86RotateDestroy (crtc);
crtc->transform_in_use = FALSE;
if (new_params)
free(new_params);
free(new_params);
new_params = NULL;
new_nparams = 0;
new_filter = NULL;
@ -506,8 +505,7 @@ xf86CrtcRotate (xf86CrtcPtr crtc)
crtc->crtc_to_framebuffer = crtc_to_fb;
crtc->f_crtc_to_framebuffer = f_crtc_to_fb;
crtc->f_framebuffer_to_crtc = f_fb_to_crtc;
if (crtc->params)
free(crtc->params);
free(crtc->params);
crtc->params = new_params;
crtc->nparams = new_nparams;
crtc->filter = new_filter;

View File

@ -451,8 +451,7 @@ xf86parseOption(XF86OptionPtr head)
if ((token = xf86getSubToken(&comment)) != STRING) {
xf86parseError(BAD_OPTION_MSG, NULL);
if (comment)
free(comment);
free(comment);
return (head);
}

View File

@ -923,8 +923,7 @@ OpenConfigDir(const char *path, const char *cmdline, const char *projroot,
if (!found) {
free(dirpath);
dirpath = NULL;
if (list)
free(list);
free(list);
}
}
@ -1088,8 +1087,7 @@ xf86validationError (char *format,...)
void
xf86setSection (char *section)
{
if (configSection)
free(configSection);
free(configSection);
configSection = malloc(strlen (section) + 1);
strcpy (configSection, section);
}

View File

@ -132,12 +132,10 @@ RamDacFreeRec(ScrnInfoPtr pScrn)
ramdacScrPtr = ((RamDacScreenRecPtr)
(pScrn)->privates[RamDacGetScreenIndex()].ptr);
if (ramdacHWPtr)
free(ramdacHWPtr);
free(ramdacHWPtr);
ramdacHWPtr = NULL;
if (ramdacScrPtr)
free(ramdacScrPtr);
free(ramdacScrPtr);
ramdacScrPtr = NULL;
}

View File

@ -1479,8 +1479,7 @@ vgaHWGetHWRecPrivate(void)
static void
vgaHWFreeRegs(vgaRegPtr regp)
{
if (regp->CRTC)
free(regp->CRTC);
free(regp->CRTC);
regp->CRTC =
regp->Sequencer =

View File

@ -148,8 +148,8 @@ XAADoBitBlt(
pboxNew2 = (BoxPtr)malloc(sizeof(BoxRec) * nbox);
pptNew2 = (DDXPointPtr)malloc(sizeof(DDXPointRec) * nbox);
if(!pboxNew2 || !pptNew2) {
if (pptNew2) free(pptNew2);
if (pboxNew2) free(pboxNew2);
free(pptNew2);
free(pboxNew2);
if (pboxNew1) {
free(pptNew1);
free(pboxNew1);

View File

@ -243,8 +243,7 @@ XAADestroyGC(GCPtr pGC)
if(pGCPriv->XAAOps != &XAAFallbackOps)
free(pGCPriv->XAAOps);
if(pGCPriv->DashPattern)
free(pGCPriv->DashPattern);
free(pGCPriv->DashPattern);
(*pGC->funcs->DestroyGC)(pGC);
XAA_GC_FUNC_EPILOGUE (pGC);

View File

@ -84,11 +84,9 @@ XAADestroyInfoRec(XAAInfoRecPtr infoRec)
if(infoRec->ClosePixmapCache)
(*infoRec->ClosePixmapCache)(infoRec->pScrn->pScreen);
if(infoRec->PreAllocMem)
free(infoRec->PreAllocMem);
free(infoRec->PreAllocMem);
if(infoRec->PixmapCachePrivate)
free(infoRec->PixmapCachePrivate);
free(infoRec->PixmapCachePrivate);
free(infoRec);
}

View File

@ -74,8 +74,7 @@ XAAComputeDash(GCPtr pGC)
int shift, value, direction;
Bool set;
if(pGCPriv->DashPattern)
free(pGCPriv->DashPattern);
free(pGCPriv->DashPattern);
pGCPriv->DashPattern = NULL;
pGCPriv->DashLength = 0;

View File

@ -144,18 +144,12 @@ FreePixmapCachePrivate(XAAPixmapCachePrivatePtr pPriv)
{
if(!pPriv) return;
if(pPriv->Info512)
free(pPriv->Info512);
if(pPriv->Info256)
free(pPriv->Info256);
if(pPriv->Info128)
free(pPriv->Info128);
if(pPriv->InfoColor)
free(pPriv->InfoColor);
if(pPriv->InfoMono)
free(pPriv->InfoMono);
if(pPriv->InfoPartial)
free(pPriv->InfoPartial);
free(pPriv->Info512);
free(pPriv->Info256);
free(pPriv->Info128);
free(pPriv->InfoColor);
free(pPriv->InfoMono);
free(pPriv->InfoPartial);
free(pPriv);
}

View File

@ -299,8 +299,7 @@ XAAGlyphBltTEColorExpansion(
skippix, ytop - Top, glyphs + skipglyphs, glyphWidth,
fg, bg, rop, planemask);
if (fallbackBits)
free(fallbackBits);
free(fallbackBits);
}
nbox--; pbox++;

View File

@ -214,8 +214,7 @@ xnestSetInstalledColormapWindows(ScreenPtr pScreen)
free(icws.cmapIDs);
if (!xnestSameInstalledColormapWindows(icws.windows, icws.numWindows)) {
if (xnestOldInstalledColormapWindows)
free(xnestOldInstalledColormapWindows);
free(xnestOldInstalledColormapWindows);
#ifdef _XSERVER64
{
@ -264,14 +263,13 @@ xnestSetInstalledColormapWindows(ScreenPtr pScreen)
#endif /* DUMB_WINDOW_MANAGERS */
}
else
if (icws.windows) free(icws.windows);
free(icws.windows);
}
void
xnestSetScreenSaverColormapWindow(ScreenPtr pScreen)
{
if (xnestOldInstalledColormapWindows)
free(xnestOldInstalledColormapWindows);
free(xnestOldInstalledColormapWindows);
#ifdef _XSERVER64
{

View File

@ -411,8 +411,7 @@ winClipboardFlushXEvents (HWND hwnd,
xtpText.value = NULL;
xtpText.nitems = 0;
}
if (pszConvertData)
free (pszConvertData);
free(pszConvertData);
if (hGlobal && pszGlobalData)
GlobalUnlock (hGlobal);
@ -773,10 +772,8 @@ winClipboardFlushXEvents (HWND hwnd,
xtpText.value = NULL;
xtpText.nitems = 0;
}
if (pszConvertData)
free (pszConvertData);
if (pwszUnicodeStr)
free (pwszUnicodeStr);
free(pszConvertData);
free(pwszUnicodeStr);
if (hGlobal && pszGlobalData)
GlobalUnlock (hGlobal);
if (fSetClipboardData && g_fUnicodeSupport)

View File

@ -144,9 +144,7 @@ winMessageBoxF (const char *pszError, UINT uType, ...)
MB_OK | uType);
winMessageBoxF_Cleanup:
if (pszErrorF)
free(pszErrorF);
if (pszMsgBox)
free(pszMsgBox);
free(pszErrorF);
free(pszMsgBox);
#undef MESSAGEBOXF
}

View File

@ -672,8 +672,7 @@ winOverrideIcon (unsigned long longWin)
{
free (res_name);
free (res_class);
if (wmName)
free (wmName);
free(wmName);
if (pref.icon[i].hicon)
return pref.icon[i].hicon;
@ -691,8 +690,7 @@ winOverrideIcon (unsigned long longWin)
/* Didn't find the icon, fail gracefully */
free (res_name);
free (res_class);
if (wmName)
free (wmName);
free(wmName);
return 0;
}
@ -849,8 +847,7 @@ winOverrideStyle (unsigned long longpWin)
{
free (res_name);
free (res_class);
if (wmName)
free (wmName);
free(wmName);
if (pref.style[i].type)
return pref.style[i].type;
@ -860,8 +857,7 @@ winOverrideStyle (unsigned long longpWin)
/* Didn't find the style, fail gracefully */
free (res_name);
free (res_class);
if (wmName)
free (wmName);
free(wmName);
return STYLE_NONE;
}

View File

@ -3081,10 +3081,8 @@ fillSpans (
(*pGC->ops->FillSpans) (pDrawable, pGC, i, xSpans, xWidths, TRUE);
}
disposeFinalSpans ();
if (xSpans)
free(xSpans);
if (xWidths)
free(xWidths);
free(xSpans);
free(xWidths);
finalMiny = 0;
finalMaxy = -1;
finalSize = 0;

View File

@ -150,12 +150,9 @@ miCopyArea(DrawablePtr pSrcDrawable,
ordering = malloc(numRects * sizeof(unsigned int));
if(!pptFirst || !pwidthFirst || !ordering)
{
if (ordering)
free(ordering);
if (pwidthFirst)
free(pwidthFirst);
if (pptFirst)
free(pptFirst);
free(ordering);
free(pwidthFirst);
free(pptFirst);
return NULL;
}
@ -433,8 +430,8 @@ miOpqStipDrawable(DrawablePtr pDraw, GCPtr pGC, RegionPtr prgnSrc,
pwidth = pwidthFirst = malloc(h * sizeof(int));
if(!pptFirst || !pwidthFirst)
{
if (pwidthFirst) free(pwidthFirst);
if (pptFirst) free(pptFirst);
free(pwidthFirst);
free(pptFirst);
FreeScratchGC(pGCT);
return;
}
@ -801,10 +798,8 @@ miPutImage( DrawablePtr pDraw, GCPtr pGC, int depth,
pwidth = pwidthFirst = malloc(h * sizeof(int));
if(!pptFirst || !pwidthFirst)
{
if (pwidthFirst)
free(pwidthFirst);
if (pptFirst)
free(pptFirst);
free(pwidthFirst);
free(pptFirst);
return;
}
if (pGC->miTranslate)

View File

@ -108,8 +108,7 @@ miCopyRegion (DrawablePtr pSrcDrawable,
pboxNew2 = (BoxPtr)malloc(sizeof(BoxRec) * nbox);
if(!pboxNew2)
{
if (pboxNew1)
free(pboxNew1);
free(pboxNew1);
return;
}
pboxBase = pboxNext = pbox;
@ -143,10 +142,8 @@ miCopyRegion (DrawablePtr pSrcDrawable,
dx, dy,
reverse, upsidedown, bitPlane, closure);
if (pboxNew1)
free(pboxNew1);
if (pboxNew2)
free(pboxNew2);
free(pboxNew1);
free(pboxNew2);
}
RegionPtr

View File

@ -111,8 +111,8 @@ miPolyFillRect(
pwFirst = malloc(maxheight * sizeof(int));
if(!pptFirst || !pwFirst)
{
if (pwFirst) free(pwFirst);
if (pptFirst) free(pptFirst);
free(pwFirst);
free(pptFirst);
return;
}

View File

@ -122,9 +122,9 @@ miFillSppPoly(
if(!ptsOut || !width || !Marked)
{
if (Marked) free(Marked);
if (width) free(width);
if (ptsOut) free(ptsOut);
free(Marked);
free(width);
free(ptsOut);
return;
}

View File

@ -109,8 +109,8 @@ miFillConvexPoly(
width = FirstWidth = malloc(sizeof(int) * dy);
if(!FirstPoint || !FirstWidth)
{
if (FirstWidth) free(FirstWidth);
if (FirstPoint) free(FirstPoint);
free(FirstWidth);
free(FirstPoint);
return(FALSE);
}

View File

@ -410,10 +410,8 @@ void miFillUniqueSpanGroup(DrawablePtr pDraw, GCPtr pGC, SpanGroup *spanGroup)
if (!yspans || !ysizes)
{
if (yspans)
free(yspans);
if (ysizes)
free(ysizes);
free(yspans);
free(ysizes);
miDisposeSpanGroup (spanGroup);
return;
}
@ -492,10 +490,8 @@ void miFillUniqueSpanGroup(DrawablePtr pDraw, GCPtr pGC, SpanGroup *spanGroup)
}
free(yspans);
free(ysizes);
if (points)
free(points);
if (widths)
free(widths);
free(points);
free(widths);
return;
}
count = 0;

View File

@ -190,8 +190,7 @@ RRCrtcNotify (RRCrtcPtr crtc,
}
else
{
if (crtc->outputs)
free(crtc->outputs);
free(crtc->outputs);
newoutputs = NULL;
}
crtc->outputs = newoutputs;
@ -440,8 +439,7 @@ RRCrtcDestroyResource (pointer value, XID pid)
}
}
}
if (crtc->gammaRed)
free(crtc->gammaRed);
free(crtc->gammaRed);
if (crtc->mode)
RRModeDestroy (crtc->mode);
free(crtc);
@ -563,8 +561,7 @@ RRCrtcGammaSetSize (RRCrtcPtr crtc,
}
else
gamma = NULL;
if (crtc->gammaRed)
free(crtc->gammaRed);
free(crtc->gammaRed);
crtc->gammaRed = gamma;
crtc->gammaGreen = gamma + size;
crtc->gammaBlue = gamma + size*2;
@ -805,8 +802,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
RROutputType, client, DixSetAttrAccess);
if (rc != Success)
{
if (outputs)
free(outputs);
free(outputs);
return rc;
}
/* validate crtc for this output */
@ -815,8 +811,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
break;
if (j == outputs[i]->numCrtcs)
{
if (outputs)
free(outputs);
free(outputs);
return BadMatch;
}
/* validate mode for this output */
@ -830,8 +825,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
}
if (j == outputs[i]->numModes + outputs[i]->numUserModes)
{
if (outputs)
free(outputs);
free(outputs);
return BadMatch;
}
}
@ -850,8 +844,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
}
if (k == outputs[i]->numClones)
{
if (outputs)
free(outputs);
free(outputs);
return BadMatch;
}
}
@ -900,8 +893,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
* Invalid rotation
*/
client->errorValue = stuff->rotation;
if (outputs)
free(outputs);
free(outputs);
return BadValue;
}
@ -913,8 +905,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
* requested rotation or reflection not supported by screen
*/
client->errorValue = stuff->rotation;
if (outputs)
free(outputs);
free(outputs);
return BadMatch;
}
@ -943,16 +934,14 @@ ProcRRSetCrtcConfig (ClientPtr client)
if (stuff->x + source_width > pScreen->width)
{
client->errorValue = stuff->x;
if (outputs)
free(outputs);
free(outputs);
return BadValue;
}
if (stuff->y + source_height > pScreen->height)
{
client->errorValue = stuff->y;
if (outputs)
free(outputs);
free(outputs);
return BadValue;
}
}
@ -979,8 +968,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
pScrPriv->lastSetTime = time;
sendReply:
if (outputs)
free(outputs);
free(outputs);
rep.type = X_Reply;
/* rep.status has already been filled in */

View File

@ -134,8 +134,7 @@ RROutputSetClones (RROutputPtr output,
}
else
newClones = NULL;
if (output->clones)
free(output->clones);
free(output->clones);
memcpy (newClones, clones, numClones * sizeof (RROutputPtr));
output->clones = newClones;
output->numClones = numClones;
@ -280,8 +279,7 @@ RROutputSetCrtcs (RROutputPtr output,
}
else
newCrtcs = NULL;
if (output->crtcs)
free(output->crtcs);
free(output->crtcs);
memcpy (newCrtcs, crtcs, numCrtcs * sizeof (RRCrtcPtr));
output->crtcs = newCrtcs;
output->numCrtcs = numCrtcs;
@ -402,13 +400,10 @@ RROutputDestroyResource (pointer value, XID pid)
for (m = 0; m < output->numUserModes; m++)
RRModeDestroy (output->userModes[m]);
if (output->userModes)
free(output->userModes);
free(output->userModes);
if (output->crtcs)
free(output->crtcs);
if (output->clones)
free(output->clones);
free(output->crtcs);
free(output->clones);
RRDeleteAllOutputProperties (output);
free(output);
return 1;

View File

@ -69,10 +69,8 @@ RRDeleteAllOutputProperties (RROutputPtr output)
event.atom = prop->propertyName;
event.timestamp = currentTime.milliseconds;
RRDeliverPropertyEvent (output->pScreen, (xEvent *)&event);
if (prop->current.data)
free(prop->current.data);
if (prop->pending.data)
free(prop->pending.data);
free(prop->current.data);
free(prop->pending.data);
free(prop);
}
}
@ -109,14 +107,10 @@ RRCreateOutputProperty (Atom property)
static void
RRDestroyOutputProperty (RRPropertyPtr prop)
{
if (prop->valid_values)
free(prop->valid_values);
if (prop->current.data)
free(prop->current.data);
if (prop->pending.data)
free(prop->pending.data);
if (prop->valid_values)
free(prop->valid_values);
free(prop->valid_values);
free(prop->current.data);
free(prop->pending.data);
free(prop->valid_values);
free(prop);
}
@ -232,12 +226,10 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type,
!pScrPriv->rrOutputSetProperty(output->pScreen, output,
prop->propertyName, &new_value))
{
if (new_value.data)
free(new_value.data);
free(new_value.data);
return (BadValue);
}
if (prop_value->data)
free(prop_value->data);
free(prop_value->data);
*prop_value = new_value;
}
@ -378,8 +370,7 @@ RRConfigureOutputProperty (RROutputPtr output, Atom property,
*/
if (prop->is_pending && !pending)
{
if (prop->pending.data)
free(prop->pending.data);
free(prop->pending.data);
RRInitOutputPropertyValue (&prop->pending);
}
@ -387,8 +378,7 @@ RRConfigureOutputProperty (RROutputPtr output, Atom property,
prop->range = range;
prop->immutable = immutable;
prop->num_valid = num_values;
if (prop->valid_values)
free(prop->valid_values);
free(prop->valid_values);
prop->valid_values = new_values;
if (add) {

View File

@ -951,8 +951,7 @@ ProcRRSetScreenConfig (ClientPtr client)
sendReply:
if (pData)
free(pData);
free(pData);
rep.type = X_Reply;
/* rep.status has already been filled in */

View File

@ -37,8 +37,7 @@ RRTransformInit (RRTransformPtr transform)
void
RRTransformFini (RRTransformPtr transform)
{
if (transform->params)
free(transform->params);
free(transform->params);
}
Bool
@ -82,8 +81,7 @@ RRTransformSetFilter (RRTransformPtr dst,
}
else
new_params = NULL;
if (dst->params)
free(dst->params);
free(dst->params);
dst->filter = filter;
dst->params = new_params;
dst->nparams = nparams;

View File

@ -1868,8 +1868,7 @@ bailout:
if (si)
{
for (i = 0; i < maxSets; i++)
if (si[i].intervals)
free(si[i].intervals);
free(si[i].intervals);
free(si);
}
if (pCanonClients && pCanonClients != (XID *)&stuff[1])
@ -1955,8 +1954,7 @@ ProcRecordCreateContext(ClientPtr client)
err = BadAlloc;
}
bailout:
if (pContext)
free(pContext);
free(pContext);
return err;
} /* ProcRecordCreateContext */
@ -2352,7 +2350,7 @@ ProcRecordGetContext(ClientPtr client)
bailout:
for (i = 0; i < nRCAPs; i++)
{
if (pRangeInfo[i].pRanges) free(pRangeInfo[i].pRanges);
free(pRangeInfo[i].pRanges);
}
free(pRangeInfo);
return err;

View File

@ -360,7 +360,7 @@ IntervalListCreateSet(RecordSetInterval *pIntervals, int nIntervals,
memcpy(&prls[1], stackIntervals, nIntervals * sizeof(RecordSetInterval));
prls->nIntervals = nIntervals;
bailout:
if (stackIntervals) free(stackIntervals);
free(stackIntervals);
return (RecordSetPtr)prls;
}

View File

@ -1524,8 +1524,7 @@ FreePicture (pointer value,
if (--pPicture->refcnt == 0)
{
if (pPicture->transform)
free(pPicture->transform);
free(pPicture->transform);
if (pPicture->pSourcePict)
{

View File

@ -183,8 +183,7 @@ _XkbClearColor(char *color_in)
{
XkbColorPtr color= (XkbColorPtr)color_in;
if (color->spec)
free(color->spec);
free(color->spec);
return;
}
@ -663,8 +662,7 @@ register XkbPropertyPtr prop;
return NULL;
for (i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
if ((prop->name)&&(strcmp(name,prop->name)==0)) {
if (prop->value)
free(prop->value);
free(prop->value);
prop->value= malloc(strlen(value)+1);
if (prop->value)
strcpy(prop->value,value);

View File

@ -312,8 +312,7 @@ KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys;
if ((map_count>type->map_count)||(type->map==NULL))
type->map = realloc(type->map,map_count * sizeof(XkbKTMapEntryRec));
if (!type->map) {
if (prev_map)
free(prev_map);
free(prev_map);
return BadAlloc;
}
if (want_preserve) {
@ -324,8 +323,7 @@ KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys;
map_count * sizeof(XkbModsRec));
}
if (!type->preserve) {
if (prev_preserve)
free(prev_preserve);
free(prev_preserve);
return BadAlloc;
}
}
@ -342,8 +340,7 @@ KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys;
type->level_names = realloc(type->level_names,
new_num_lvls * sizeof(Atom));
if (!type->level_names) {
if (prev_level_names)
free(prev_level_names);
free(prev_level_names);
return BadAlloc;
}
}

View File

@ -553,9 +553,9 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
static void
FreeMultiDefs(XkbRF_MultiDefsPtr defs)
{
if (defs->options) free(defs->options);
if (defs->layout[1]) free(defs->layout[1]);
if (defs->variant[1]) free(defs->variant[1]);
free(defs->options);
free(defs->layout[1]);
free(defs->variant[1]);
}
static void
@ -988,15 +988,15 @@ XkbRF_GroupPtr group;
return;
if (rules->rules) {
for (i=0,rule=rules->rules;i<rules->num_rules;i++,rule++) {
if (rule->model) free(rule->model);
if (rule->layout) free(rule->layout);
if (rule->variant) free(rule->variant);
if (rule->option) free(rule->option);
if (rule->keycodes) free(rule->keycodes);
if (rule->symbols) free(rule->symbols);
if (rule->types) free(rule->types);
if (rule->compat) free(rule->compat);
if (rule->geometry) free(rule->geometry);
free(rule->model);
free(rule->layout);
free(rule->variant);
free(rule->option);
free(rule->keycodes);
free(rule->symbols);
free(rule->types);
free(rule->compat);
free(rule->geometry);
memset((char *)rule, 0, sizeof(XkbRF_RuleRec));
}
free(rules->rules);
@ -1006,8 +1006,8 @@ XkbRF_GroupPtr group;
if (rules->groups) {
for (i=0, group=rules->groups;i<rules->num_groups;i++,group++) {
if (group->name) free(group->name);
if (group->words) free(group->words);
free(group->name);
free(group->words);
}
free(rules->groups);
rules->num_groups= 0;

View File

@ -220,20 +220,15 @@ char * pval;
static void
XkbSetRulesUsed(XkbRMLVOSet *rmlvo)
{
if (XkbRulesUsed)
free(XkbRulesUsed);
free(XkbRulesUsed);
XkbRulesUsed= (rmlvo->rules?_XkbDupString(rmlvo->rules):NULL);
if (XkbModelUsed)
free(XkbModelUsed);
free(XkbModelUsed);
XkbModelUsed= (rmlvo->model?_XkbDupString(rmlvo->model):NULL);
if (XkbLayoutUsed)
free(XkbLayoutUsed);
free(XkbLayoutUsed);
XkbLayoutUsed= (rmlvo->layout?_XkbDupString(rmlvo->layout):NULL);
if (XkbVariantUsed)
free(XkbVariantUsed);
free(XkbVariantUsed);
XkbVariantUsed= (rmlvo->variant?_XkbDupString(rmlvo->variant):NULL);
if (XkbOptionsUsed)
free(XkbOptionsUsed);
free(XkbOptionsUsed);
XkbOptionsUsed= (rmlvo->options?_XkbDupString(rmlvo->options):NULL);
if (XkbWantRulesProp)
QueueWorkProc(XkbWriteRulesProp,NULL,NULL);
@ -244,28 +239,23 @@ void
XkbSetRulesDflts(XkbRMLVOSet *rmlvo)
{
if (rmlvo->rules) {
if (XkbRulesDflt)
free(XkbRulesDflt);
free(XkbRulesDflt);
XkbRulesDflt= _XkbDupString(rmlvo->rules);
}
if (rmlvo->model) {
if (XkbModelDflt)
free(XkbModelDflt);
free(XkbModelDflt);
XkbModelDflt= _XkbDupString(rmlvo->model);
}
if (rmlvo->layout) {
if (XkbLayoutDflt)
free(XkbLayoutDflt);
free(XkbLayoutDflt);
XkbLayoutDflt= _XkbDupString(rmlvo->layout);
}
if (rmlvo->variant) {
if (XkbVariantDflt)
free(XkbVariantDflt);
free(XkbVariantDflt);
XkbVariantDflt= _XkbDupString(rmlvo->variant);
}
if (rmlvo->options) {
if (XkbOptionsDflt)
free(XkbOptionsDflt);
free(XkbOptionsDflt);
XkbOptionsDflt= _XkbDupString(rmlvo->options);
}
return;

View File

@ -605,8 +605,8 @@ void
XkbFreeSrvLedInfo(XkbSrvLedInfoPtr sli)
{
if ((sli->flags&XkbSLI_IsDefault)==0) {
if (sli->maps) free(sli->maps);
if (sli->names) free(sli->names);
free(sli->maps);
free(sli->names);
}
sli->maps= NULL;
sli->names= NULL;