From f4190feb25ecc3d8278decc8bf28a5ef0e568942 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Thu, 10 Jun 2010 04:08:54 +0700 Subject: Remove more superfluous if(p) checks around free(p) Reviewed-by: Alan Coopersmith Signed-off-by: Matt Turner Signed-off-by: Mikhail Gusarov --- xkb/XKBGAlloc.c | 18 ++++++------------ xkb/XKBMAlloc.c | 18 ++++++------------ xkb/ddxList.c | 5 +---- xkb/xkb.c | 21 ++++++++++++--------- xkb/xkbInit.c | 6 ++---- 5 files changed, 27 insertions(+), 41 deletions(-) (limited to 'xkb') diff --git a/xkb/XKBGAlloc.c b/xkb/XKBGAlloc.c index 796931cf4..d1adea34e 100644 --- a/xkb/XKBGAlloc.c +++ b/xkb/XKBGAlloc.c @@ -114,10 +114,8 @@ register char *ptr; } if (freeAll) { (*num_inout)= (*sz_inout)= 0; - if (*elems) { - free(*elems); - *elems= NULL; - } + free(*elems); + *elems = NULL; } else if (first+count>=(*num_inout)) *num_inout= first; @@ -137,14 +135,10 @@ _XkbClearProperty(char *prop_in) { XkbPropertyPtr prop= (XkbPropertyPtr)prop_in; - if (prop->name) { - free(prop->name); - prop->name= NULL; - } - if (prop->value) { - free(prop->value); - prop->value= NULL; - } + free(prop->name); + prop->name = NULL; + free(prop->value); + prop->value = NULL; return; } diff --git a/xkb/XKBMAlloc.c b/xkb/XKBMAlloc.c index 197523f57..6b186c1ad 100644 --- a/xkb/XKBMAlloc.c +++ b/xkb/XKBMAlloc.c @@ -221,18 +221,12 @@ XkbCopyKeyType(XkbKeyTypePtr from,XkbKeyTypePtr into) { if ((!from)||(!into)) return BadMatch; - if (into->map) { - free(into->map); - into->map= NULL; - } - if (into->preserve) { - free(into->preserve); - into->preserve= NULL; - } - if (into->level_names) { - free(into->level_names); - into->level_names= NULL; - } + free(into->map); + into->map = NULL; + free(into->preserve); + into->preserve = NULL; + free(into->level_names); + into->level_names = NULL; *into= *from; if ((from->map)&&(into->map_count>0)) { into->map= calloc(into->map_count, sizeof(XkbKTMapEntryRec)); diff --git a/xkb/ddxList.c b/xkb/ddxList.c index eee388749..2256424d0 100644 --- a/xkb/ddxList.c +++ b/xkb/ddxList.c @@ -208,10 +208,7 @@ char tmpname[PATH_MAX]; return BadImplementation; } list->nFound[what]= 0; - if (buf) { - free(buf); - buf = NULL; - } + free(buf); buf = malloc(PATH_MAX * sizeof(char)); if (!buf) return BadAlloc; diff --git a/xkb/xkb.c b/xkb/xkb.c index cbb46c62f..bd73e9a8e 100644 --- a/xkb/xkb.c +++ b/xkb/xkb.c @@ -5510,10 +5510,8 @@ ProcXkbListComponents(ClientPtr client) if ((XkbPaddedSize(len)/4)!=stuff->length) return BadLength; if ((status=XkbDDXList(dev,&list,client))!=Success) { - if (list.pool) { - free(list.pool); - list.pool= NULL; - } + free(list.pool); + list.pool = NULL; return status; } memset(&rep, 0, sizeof(xkbListComponentsReply)); @@ -5886,11 +5884,16 @@ ProcXkbGetKbdByName(ClientPtr client) XkbFreeKeyboard(new,XkbAllComponentsMask,TRUE); new= NULL; } - if (names.keycodes) { free(names.keycodes); names.keycodes= NULL; } - if (names.types) { free(names.types); names.types= NULL; } - if (names.compat) { free(names.compat); names.compat= NULL; } - if (names.symbols) { free(names.symbols); names.symbols= NULL; } - if (names.geometry) { free(names.geometry); names.geometry= NULL; } + free(names.keycodes); + names.keycodes = NULL; + free(names.types); + names.types = NULL; + free(names.compat); + names.compat = NULL; + free(names.symbols); + names.symbols = NULL; + free(names.geometry); + names.geometry = NULL; return Success; } diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c index bd58243ca..fbf8f14b8 100644 --- a/xkb/xkbInit.c +++ b/xkb/xkbInit.c @@ -635,10 +635,8 @@ unwind_key: void XkbFreeInfo(XkbSrvInfoPtr xkbi) { - if (xkbi->radioGroups) { - free(xkbi->radioGroups); - xkbi->radioGroups= NULL; - } + free(xkbi->radioGroups); + xkbi->radioGroups = NULL; if (xkbi->mouseKeyTimer) { TimerFree(xkbi->mouseKeyTimer); xkbi->mouseKeyTimer= NULL; -- cgit v1.2.3