Commit 1ff69612 authored by walter harms's avatar walter harms Committed by Ulrich Sibiller

Remove more redundant null checks before Xfree()

parent fc26b97e
...@@ -553,9 +553,7 @@ static void ...@@ -553,9 +553,7 @@ static void
_free_memory_for_text(XIMText* text) _free_memory_for_text(XIMText* text)
{ {
if (text) { if (text) {
if (text->string.multi_byte)
Xfree(text->string.multi_byte); Xfree(text->string.multi_byte);
if (text->feedback)
Xfree(text->feedback); Xfree(text->feedback);
Xfree(text); Xfree(text);
} }
......
...@@ -1568,9 +1568,8 @@ _XimProtoCreateIC( ...@@ -1568,9 +1568,8 @@ _XimProtoCreateIC(
ErrorOnCreatingIC: ErrorOnCreatingIC:
_XimUnregisterFilter(ic); _XimUnregisterFilter(ic);
if (ic->private.proto.ic_resources)
Xfree(ic->private.proto.ic_resources); Xfree(ic->private.proto.ic_resources);
if (ic->private.proto.ic_inner_resources)
Xfree(ic->private.proto.ic_inner_resources); Xfree(ic->private.proto.ic_inner_resources);
Xfree(ic); Xfree(ic);
return (XIC)NULL; return (XIC)NULL;
......
...@@ -1775,9 +1775,7 @@ _XimEncodingNegotiation( ...@@ -1775,9 +1775,7 @@ _XimEncodingNegotiation(
detail_ptr, detail_len))) detail_ptr, detail_len)))
goto free_preply; goto free_preply;
if (name_ptr)
Xfree(name_ptr); Xfree(name_ptr);
if (detail_ptr)
Xfree(detail_ptr); Xfree(detail_ptr);
if(reply != preply) if(reply != preply)
......
...@@ -599,9 +599,8 @@ _XimUnregCommitInfo( ...@@ -599,9 +599,8 @@ _XimUnregCommitInfo(
if (!(info = ic->private.proto.commit_info)) if (!(info = ic->private.proto.commit_info))
return; return;
if (info->string)
Xfree(info->string); Xfree(info->string);
if (info->keysym)
Xfree(info->keysym); Xfree(info->keysym);
ic->private.proto.commit_info = info->next; ic->private.proto.commit_info = info->next;
Xfree(info); Xfree(info);
...@@ -696,9 +695,7 @@ _XimCommitRecv( ...@@ -696,9 +695,7 @@ _XimCommitRecv(
} }
if (!(_XimRegCommitInfo(ic, string, string_len, keysym, keysym_len))) { if (!(_XimRegCommitInfo(ic, string, string_len, keysym, keysym_len))) {
if (string)
Xfree(string); Xfree(string);
if (keysym)
Xfree(keysym); Xfree(keysym);
_XimError(im, ic, XIM_BadAlloc, (INT16)0, (CARD16)0, (char *)NULL); _XimError(im, ic, XIM_BadAlloc, (INT16)0, (CARD16)0, (char *)NULL);
return False; return False;
......
...@@ -239,13 +239,10 @@ Error4 : ...@@ -239,13 +239,10 @@ Error4 :
Xfree(im); Xfree(im);
return NULL; return NULL;
Error3 : Error3 :
if(im->core.im_name)
Xfree(im->core.im_name); Xfree(im->core.im_name);
Error2: Error2:
if(im->core.res_class)
Xfree(im->core.res_class); Xfree(im->core.res_class);
Error1: Error1:
if(im->core.res_name)
Xfree(im->core.res_name); Xfree(im->core.res_name);
Xfree(im); Xfree(im);
return NULL; return NULL;
......
...@@ -131,13 +131,14 @@ XimFreeDefaultTree( ...@@ -131,13 +131,14 @@ XimFreeDefaultTree(
} }
#endif #endif
Xfree (b->tree); Xfree (b->tree);
if (b->mb) Xfree (b->mb);
if (b->wc) Xfree (b->wc);
if (b->utf8) Xfree (b->utf8);
b->tree = NULL; b->tree = NULL;
Xfree (b->mb);
b->mb = NULL; b->mb = NULL;
Xfree (b->wc);
b->wc = NULL; b->wc = NULL;
Xfree (b->utf8);
b->utf8 = NULL; b->utf8 = NULL;
b->treeused = b->treesize = 0; b->treeused = b->treesize = 0;
b->mbused = b->mbsize = 0; b->mbused = b->mbsize = 0;
b->wcused = b->wcsize = 0; b->wcused = b->wcsize = 0;
...@@ -151,38 +152,30 @@ _XimLocalIMFree( ...@@ -151,38 +152,30 @@ _XimLocalIMFree(
XimFreeDefaultTree(&im->private.local.base); XimFreeDefaultTree(&im->private.local.base);
im->private.local.top = 0; im->private.local.top = 0;
if(im->core.im_resources) {
Xfree(im->core.im_resources); Xfree(im->core.im_resources);
im->core.im_resources = NULL; im->core.im_resources = NULL;
}
if(im->core.ic_resources) {
Xfree(im->core.ic_resources); Xfree(im->core.ic_resources);
im->core.ic_resources = NULL; im->core.ic_resources = NULL;
}
if(im->core.im_values_list) {
Xfree(im->core.im_values_list); Xfree(im->core.im_values_list);
im->core.im_values_list = NULL; im->core.im_values_list = NULL;
}
if(im->core.ic_values_list) {
Xfree(im->core.ic_values_list); Xfree(im->core.ic_values_list);
im->core.ic_values_list = NULL; im->core.ic_values_list = NULL;
}
if(im->core.styles) {
Xfree(im->core.styles); Xfree(im->core.styles);
im->core.styles = NULL; im->core.styles = NULL;
}
if(im->core.res_name) {
Xfree(im->core.res_name); Xfree(im->core.res_name);
im->core.res_name = NULL; im->core.res_name = NULL;
}
if(im->core.res_class) {
Xfree(im->core.res_class); Xfree(im->core.res_class);
im->core.res_class = NULL; im->core.res_class = NULL;
}
if(im->core.im_name) {
Xfree(im->core.im_name); Xfree(im->core.im_name);
im->core.im_name = NULL; im->core.im_name = NULL;
}
if (im->private.local.ctom_conv) { if (im->private.local.ctom_conv) {
_XlcCloseConverter(im->private.local.ctom_conv); _XlcCloseConverter(im->private.local.ctom_conv);
im->private.local.ctom_conv = NULL; im->private.local.ctom_conv = NULL;
...@@ -576,18 +569,14 @@ _XimCreateDefaultTree( ...@@ -576,18 +569,14 @@ _XimCreateDefaultTree(
encoding, 0, 1, &cachename, &size); encoding, 0, 1, &cachename, &size);
if (cachefd != -1) { if (cachefd != -1) {
if (_XimLoadCache (cachefd, intname, encoding, size, im)) { if (_XimLoadCache (cachefd, intname, encoding, size, im)) {
if (tmpcachedir)
Xfree (tmpcachedir); Xfree (tmpcachedir);
if (tmpname)
Xfree (tmpname); Xfree (tmpname);
if (cachename)
Xfree (cachename); Xfree (cachename);
close (cachefd); close (cachefd);
return; return;
} }
close (cachefd); close (cachefd);
} }
if (cachename)
Xfree (cachename); Xfree (cachename);
cachename = NULL; cachename = NULL;
} }
...@@ -603,11 +592,8 @@ _XimCreateDefaultTree( ...@@ -603,11 +592,8 @@ _XimCreateDefaultTree(
euid, 0, &cachename, &size); euid, 0, &cachename, &size);
if (cachefd != -1) { if (cachefd != -1) {
if (_XimLoadCache (cachefd, intname, encoding, size, im)) { if (_XimLoadCache (cachefd, intname, encoding, size, im)) {
if (tmpcachedir)
Xfree (tmpcachedir); Xfree (tmpcachedir);
if (tmpname)
Xfree (tmpname); Xfree (tmpname);
if (cachename)
Xfree (cachename); Xfree (cachename);
close (cachefd); close (cachefd);
return; return;
...@@ -618,11 +604,8 @@ _XimCreateDefaultTree( ...@@ -618,11 +604,8 @@ _XimCreateDefaultTree(
#endif #endif
if (! (fp = _XFopenFile (name, "r"))) { if (! (fp = _XFopenFile (name, "r"))) {
if (tmpcachedir)
Xfree (tmpcachedir); Xfree (tmpcachedir);
if (tmpname)
Xfree (tmpname); Xfree (tmpname);
if (cachename)
Xfree (cachename); Xfree (cachename);
return; return;
} }
...@@ -636,11 +619,8 @@ _XimCreateDefaultTree( ...@@ -636,11 +619,8 @@ _XimCreateDefaultTree(
} }
#endif #endif
if (tmpcachedir)
Xfree (tmpcachedir); Xfree (tmpcachedir);
if (tmpname)
Xfree (tmpname); Xfree (tmpname);
if (cachename)
Xfree (cachename); Xfree (cachename);
} }
......
...@@ -972,7 +972,6 @@ _XimEncodePreeditValue( ...@@ -972,7 +972,6 @@ _XimEncodePreeditValue(
if (!p->value) if (!p->value)
return False; return False;
if (ic->private.proto.preedit_font)
Xfree(ic->private.proto.preedit_font); Xfree(ic->private.proto.preedit_font);
list_ret = XFontsOfFontSet((XFontSet)p->value, list_ret = XFontsOfFontSet((XFontSet)p->value,
...@@ -1024,7 +1023,6 @@ _XimEncodeStatusValue( ...@@ -1024,7 +1023,6 @@ _XimEncodeStatusValue(
if (!p->value) if (!p->value)
return False; return False;
if (ic->private.proto.status_font)
Xfree(ic->private.proto.status_font); Xfree(ic->private.proto.status_font);
list_ret = XFontsOfFontSet((XFontSet)p->value, list_ret = XFontsOfFontSet((XFontSet)p->value,
...@@ -1243,7 +1241,6 @@ _XimEncodeSavedStatusValue( ...@@ -1243,7 +1241,6 @@ _XimEncodeSavedStatusValue(
if (!value) if (!value)
return False; return False;
if (ic->private.proto.status_font)
Xfree(ic->private.proto.status_font); Xfree(ic->private.proto.status_font);
list_ret = XFontsOfFontSet((XFontSet)value, list_ret = XFontsOfFontSet((XFontSet)value,
...@@ -1460,10 +1457,9 @@ _XimGetAttributeID( ...@@ -1460,10 +1457,9 @@ _XimGetAttributeID(
} }
_XIMCompileResourceList(res, n); _XIMCompileResourceList(res, n);
if (im->core.im_resources)
Xfree(im->core.im_resources); Xfree(im->core.im_resources);
if (im->core.im_values_list)
Xfree(im->core.im_values_list); Xfree(im->core.im_values_list);
im->core.im_resources = res; im->core.im_resources = res;
im->core.im_num_resources = n; im->core.im_num_resources = n;
im->core.im_values_list = values_list; im->core.im_values_list = values_list;
...@@ -1506,10 +1502,10 @@ _XimGetAttributeID( ...@@ -1506,10 +1502,10 @@ _XimGetAttributeID(
} }
_XIMCompileResourceList(res, n); _XIMCompileResourceList(res, n);
if (im->core.ic_resources)
Xfree(im->core.ic_resources); Xfree(im->core.ic_resources);
if (im->core.ic_values_list)
Xfree(im->core.ic_values_list); Xfree(im->core.ic_values_list);
im->core.ic_resources = res; im->core.ic_resources = res;
im->core.ic_num_resources = n; im->core.ic_num_resources = n;
im->core.ic_values_list = values_list; im->core.ic_values_list = values_list;
......
...@@ -65,18 +65,20 @@ _XimThaiDestroyIC( ...@@ -65,18 +65,20 @@ _XimThaiDestroyIC(
if(((Xim)ic->core.im)->private.local.current_ic == (XIC)ic) { if(((Xim)ic->core.im)->private.local.current_ic == (XIC)ic) {
_XimThaiUnSetFocus(xic); _XimThaiUnSetFocus(xic);
} }
if(ic->private.local.ic_resources) {
Xfree(ic->private.local.ic_resources); Xfree(ic->private.local.ic_resources);
ic->private.local.ic_resources = NULL; ic->private.local.ic_resources = NULL;
}
if (b->tree) Xfree (b->tree); Xfree (b->tree);
if (b->mb) Xfree (b->mb);
if (b->wc) Xfree (b->wc);
if (b->utf8) Xfree (b->utf8);
b->tree = NULL; b->tree = NULL;
Xfree (b->mb);
b->mb = NULL; b->mb = NULL;
Xfree (b->wc);
b->wc = NULL; b->wc = NULL;
Xfree (b->utf8);
b->utf8 = NULL; b->utf8 = NULL;
return; return;
} }
......
...@@ -563,9 +563,8 @@ static void ...@@ -563,9 +563,8 @@ static void
close_converter( close_converter(
XlcConv conv) XlcConv conv)
{ {
if (conv->state)
Xfree(conv->state);
Xfree(conv->state);
Xfree(conv); Xfree(conv);
} }
......
...@@ -1225,7 +1225,6 @@ stdc_wcstocts( ...@@ -1225,7 +1225,6 @@ stdc_wcstocts(
goto ret; goto ret;
ret: ret:
if (buf)
Xfree(buf); Xfree(buf);
return (unconv_num1 + unconv_num2); return (unconv_num1 + unconv_num2);
...@@ -1548,7 +1547,6 @@ stdc_ctstowcs( ...@@ -1548,7 +1547,6 @@ stdc_ctstowcs(
goto ret; goto ret;
ret: ret:
if (buf)
Xfree(buf); Xfree(buf);
return (unconv_num1 + unconv_num2); return (unconv_num1 + unconv_num2);
...@@ -1584,7 +1582,6 @@ stdc_cstowcs( ...@@ -1584,7 +1582,6 @@ stdc_cstowcs(
goto ret; goto ret;
ret: ret:
if (buf)
Xfree(buf); Xfree(buf);
return (unconv_num1 + unconv_num2); return (unconv_num1 + unconv_num2);
...@@ -1620,7 +1617,6 @@ mbstocts( ...@@ -1620,7 +1617,6 @@ mbstocts(
goto ret; goto ret;
ret: ret:
if (buf)
Xfree(buf); Xfree(buf);
return (unconv_num1 + unconv_num2); return (unconv_num1 + unconv_num2);
...@@ -2071,7 +2067,6 @@ stdc_wcstostr( ...@@ -2071,7 +2067,6 @@ stdc_wcstostr(
goto ret; goto ret;
ret: ret:
if (buf)
Xfree(buf); Xfree(buf);
return (unconv_num1 + unconv_num2); return (unconv_num1 + unconv_num2);
...@@ -2346,7 +2341,6 @@ ctstombs( ...@@ -2346,7 +2341,6 @@ ctstombs(
goto ret; goto ret;
ret: ret:
if (buf)
Xfree(buf); Xfree(buf);
return (unconv_num1 + unconv_num2); return (unconv_num1 + unconv_num2);
...@@ -2382,7 +2376,6 @@ cstombs( ...@@ -2382,7 +2376,6 @@ cstombs(
goto ret; goto ret;
ret: ret:
if (buf)
Xfree(buf); Xfree(buf);
return (unconv_num1 + unconv_num2); return (unconv_num1 + unconv_num2);
...@@ -2591,7 +2584,6 @@ stdc_strtowcs( ...@@ -2591,7 +2584,6 @@ stdc_strtowcs(
goto ret; goto ret;
ret: ret:
if (buf)
Xfree(buf); Xfree(buf);
return (unconv_num1 + unconv_num2); return (unconv_num1 + unconv_num2);
...@@ -2605,14 +2597,8 @@ static void ...@@ -2605,14 +2597,8 @@ static void
close_converter( close_converter(
XlcConv conv) XlcConv conv)
{ {
if (conv->state) {
Xfree(conv->state); Xfree(conv->state);
}
if (conv->methods) {
Xfree(conv->methods); Xfree(conv->methods);
}
Xfree(conv); Xfree(conv);
} }
......
...@@ -196,15 +196,11 @@ init_fontset( ...@@ -196,15 +196,11 @@ init_fontset(
return True; return True;
err: err:
if(font_set->font_data)
Xfree(font_set->font_data); Xfree(font_set->font_data);
if(font_set->substitute)
Xfree(font_set->substitute); Xfree(font_set->substitute);
if(font_set->vmap)
Xfree(font_set->vmap); Xfree(font_set->vmap);
if(font_set->vrotate)
Xfree(font_set->vrotate); Xfree(font_set->vrotate);
if(font_set)
Xfree(font_set); Xfree(font_set);
gen->font_set = (FontSet) NULL; gen->font_set = (FontSet) NULL;
gen->font_set_num = 0; gen->font_set_num = 0;
...@@ -504,7 +500,7 @@ init_core_part( ...@@ -504,7 +500,7 @@ init_core_part(
return True; return True;
err: err:
if (font_name_list)
Xfree(font_name_list); Xfree(font_name_list);
Xfree(font_struct_list); Xfree(font_struct_list);
...@@ -1486,23 +1482,14 @@ destroy_oc( ...@@ -1486,23 +1482,14 @@ destroy_oc(
*/ */
/* For VW/UDC end */ /* For VW/UDC end */
if (oc->core.base_name_list)
Xfree(oc->core.base_name_list); Xfree(oc->core.base_name_list);
if (oc->core.font_info.font_name_list)
XFreeStringList(oc->core.font_info.font_name_list); XFreeStringList(oc->core.font_info.font_name_list);
if (oc->core.font_info.font_struct_list) {
Xfree(oc->core.font_info.font_struct_list); Xfree(oc->core.font_info.font_struct_list);
}
if (oc->core.missing_list.charset_list)
XFreeStringList(oc->core.missing_list.charset_list); XFreeStringList(oc->core.missing_list.charset_list);
#ifdef notdef #ifdef notdef
if (oc->core.res_name)
Xfree(oc->core.res_name); Xfree(oc->core.res_name);
if (oc->core.res_class)
Xfree(oc->core.res_class); Xfree(oc->core.res_class);
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment