Commit dde00b2f authored by Alan Coopersmith's avatar Alan Coopersmith Committed by Ulrich Sibiller

Convert malloc(strlen()); strcpy() sets to strdup

parent 7d7224d8
...@@ -85,10 +85,9 @@ _XParseBaseFontNameList( ...@@ -85,10 +85,9 @@ _XParseBaseFontNameList(
if (!*str) if (!*str)
return (char **)NULL; return (char **)NULL;
if (!(ptr = Xmalloc((unsigned)strlen(str) + 1))) { if (!(ptr = strdup(str))) {
return (char **)NULL; return (char **)NULL;
} }
strcpy(ptr, str);
psave = ptr; psave = ptr;
/* somebody who specifies more than XMAXLIST basefontnames will lose */ /* somebody who specifies more than XMAXLIST basefontnames will lose */
......
...@@ -50,14 +50,13 @@ XExtCodes *XInitExtension ( ...@@ -50,14 +50,13 @@ XExtCodes *XInitExtension (
LockDisplay (dpy); LockDisplay (dpy);
if (! (ext = (_XExtension *) Xcalloc (1, sizeof (_XExtension))) || if (! (ext = (_XExtension *) Xcalloc (1, sizeof (_XExtension))) ||
! (ext->name = Xmalloc((unsigned) strlen(name) + 1))) { ! (ext->name = strdup(name))) {
if (ext) Xfree((char *) ext); if (ext) Xfree((char *) ext);
UnlockDisplay(dpy); UnlockDisplay(dpy);
return (XExtCodes *) NULL; return (XExtCodes *) NULL;
} }
codes.extension = dpy->ext_number++; codes.extension = dpy->ext_number++;
ext->codes = codes; ext->codes = codes;
(void) strcpy(ext->name, name);
/* chain it onto the display list */ /* chain it onto the display list */
ext->next = dpy->ext_procs; ext->next = dpy->ext_procs;
......
...@@ -66,7 +66,6 @@ XcmsPrefixOfFormat( ...@@ -66,7 +66,6 @@ XcmsPrefixOfFormat(
*/ */
{ {
XcmsColorSpace **papColorSpaces; XcmsColorSpace **papColorSpaces;
char *prefix;
/* /*
* First try Device-Independent color spaces * First try Device-Independent color spaces
...@@ -75,10 +74,7 @@ XcmsPrefixOfFormat( ...@@ -75,10 +74,7 @@ XcmsPrefixOfFormat(
if (papColorSpaces != NULL) { if (papColorSpaces != NULL) {
while (*papColorSpaces != NULL) { while (*papColorSpaces != NULL) {
if ((*papColorSpaces)->id == id) { if ((*papColorSpaces)->id == id) {
prefix = (char *)Xmalloc((strlen((*papColorSpaces)->prefix) + return strdup((*papColorSpaces)->prefix);
1) * sizeof(char));
strcpy(prefix, (*papColorSpaces)->prefix);
return(prefix);
} }
papColorSpaces++; papColorSpaces++;
} }
...@@ -91,10 +87,7 @@ XcmsPrefixOfFormat( ...@@ -91,10 +87,7 @@ XcmsPrefixOfFormat(
if (papColorSpaces != NULL) { if (papColorSpaces != NULL) {
while (*papColorSpaces != NULL) { while (*papColorSpaces != NULL) {
if ((*papColorSpaces)->id == id) { if ((*papColorSpaces)->id == id) {
prefix = (char *)Xmalloc((strlen((*papColorSpaces)->prefix) + return strdup((*papColorSpaces)->prefix);
1) * sizeof(char));
strcpy(prefix, (*papColorSpaces)->prefix);
return(prefix);
} }
papColorSpaces++; papColorSpaces++;
} }
......
...@@ -103,13 +103,12 @@ _Xsetlocale( ...@@ -103,13 +103,12 @@ _Xsetlocale(
if (!methods) if (!methods)
return NULL; return NULL;
name = (*methods->lcname)(state); name = (*methods->lcname)(state);
xsl_name = Xmalloc(strlen(name) + 1); xsl_name = strdup(name);
if (!xsl_name) { if (!xsl_name) {
xsl_name = old_name; xsl_name = old_name;
(*methods->destroy)(state); (*methods->destroy)(state);
return NULL; return NULL;
} }
strcpy(xsl_name, name);
if (old_name) if (old_name)
Xfree(old_name); Xfree(old_name);
(*methods->destroy)(state); (*methods->destroy)(state);
......
...@@ -226,12 +226,10 @@ _XDefaultOpenIM( ...@@ -226,12 +226,10 @@ _XDefaultOpenIM(
local_impart->ctow_conv = ctow_conv; local_impart->ctow_conv = ctow_conv;
if ((res_name != NULL) && (*res_name != '\0')){ if ((res_name != NULL) && (*res_name != '\0')){
im->core.res_name = (char *)Xmalloc(strlen(res_name)+1); im->core.res_name = strdup(res_name);
strcpy(im->core.res_name,res_name);
} }
if ((res_class != NULL) && (*res_class != '\0')){ if ((res_class != NULL) && (*res_class != '\0')){
im->core.res_class = (char *)Xmalloc(strlen(res_class)+1); im->core.res_class = strdup(res_class);
strcpy(im->core.res_class,res_class);
} }
return (XIM)im; return (XIM)im;
......
...@@ -216,9 +216,8 @@ check_fontname( ...@@ -216,9 +216,8 @@ check_fontname(
fname = prop_fname; fname = prop_fname;
} }
if (data) { if (data) {
font_set->font_name = (char *) Xmalloc(strlen(fname) + 1); font_set->font_name = strdup(fname);
if (font_set->font_name) { if (font_set->font_name) {
strcpy(font_set->font_name, fname);
found_num++; found_num++;
} }
} }
...@@ -387,9 +386,7 @@ get_font_name( ...@@ -387,9 +386,7 @@ get_font_name(
list = XListFonts(dpy, pattern, 1, &count); list = XListFonts(dpy, pattern, 1, &count);
if (list != NULL) { if (list != NULL) {
name = (char *) Xmalloc(strlen(*list) + 1); name = strdup(*list);
if (name)
strcpy(name, *list);
XFreeFontNames(list); XFreeFontNames(list);
} else { } else {
...@@ -459,13 +456,11 @@ parse_fontname( ...@@ -459,13 +456,11 @@ parse_fontname(
if (font_data == NULL) if (font_data == NULL)
continue; continue;
font_set->font_name = (char *) Xmalloc(strlen(font_name) + 1); font_set->font_name = strdup(font_name);
Xfree(font_name);
if (font_set->font_name == NULL) { if (font_set->font_name == NULL) {
Xfree(font_name);
goto err; goto err;
} }
strcpy(font_set->font_name, font_name);
Xfree(font_name);
found_num++; found_num++;
goto found; goto found;
} }
...@@ -548,11 +543,10 @@ Limit the length of the string copy to prevent stack corruption. ...@@ -548,11 +543,10 @@ Limit the length of the string copy to prevent stack corruption.
} }
} }
found: found:
base_name = (char *) Xmalloc(strlen(oc->core.base_name_list) + 1); base_name = strdup(oc->core.base_name_list);
if (base_name == NULL) if (base_name == NULL)
goto err; goto err;
strcpy(base_name, oc->core.base_name_list);
oc->core.base_name_list = base_name; oc->core.base_name_list = base_name;
XFreeStringList(name_list); XFreeStringList(name_list);
...@@ -1177,10 +1171,9 @@ This one is fine. *value points to one of the local strings in ...@@ -1177,10 +1171,9 @@ This one is fine. *value points to one of the local strings in
supported_charset_list[]. supported_charset_list[].
*/ */
strcpy(buf, *value++); strcpy(buf, *value++);
font_data->name = (char *) Xmalloc(strlen(buf) + 1); font_data->name = strdup(buf);
if (font_data->name == NULL) if (font_data->name == NULL)
return False; return False;
strcpy(font_data->name, buf);
} }
length += strlen(data->font_data->name) + 1; length += strlen(data->font_data->name) + 1;
...@@ -1241,16 +1234,14 @@ _XDefaultOpenOM(XLCd lcd, Display *dpy, XrmDatabase rdb, ...@@ -1241,16 +1234,14 @@ _XDefaultOpenOM(XLCd lcd, Display *dpy, XrmDatabase rdb,
om->core.display = dpy; om->core.display = dpy;
om->core.rdb = rdb; om->core.rdb = rdb;
if (res_name) { if (res_name) {
om->core.res_name = (char *)Xmalloc(strlen(res_name) + 1); om->core.res_name = strdup(res_name);
if (om->core.res_name == NULL) if (om->core.res_name == NULL)
goto err; goto err;
strcpy(om->core.res_name, res_name);
} }
if (res_class) { if (res_class) {
om->core.res_class = (char *)Xmalloc(strlen(res_class) + 1); om->core.res_class = strdup(res_class);
if (om->core.res_class == NULL) if (om->core.res_class == NULL)
goto err; goto err;
strcpy(om->core.res_class, res_class);
} }
if (om_resources[0].xrm_name == NULLQUARK) if (om_resources[0].xrm_name == NULLQUARK)
......
...@@ -684,9 +684,7 @@ register XkbPropertyPtr prop; ...@@ -684,9 +684,7 @@ register XkbPropertyPtr prop;
if ((prop->name)&&(strcmp(name,prop->name)==0)) { if ((prop->name)&&(strcmp(name,prop->name)==0)) {
if (prop->value) if (prop->value)
_XkbFree(prop->value); _XkbFree(prop->value);
prop->value= (char *)_XkbAlloc(strlen(value)+1); prop->value= strdup(value);
if (prop->value)
strcpy(prop->value,value);
return prop; return prop;
} }
} }
...@@ -695,17 +693,15 @@ register XkbPropertyPtr prop; ...@@ -695,17 +693,15 @@ register XkbPropertyPtr prop;
return NULL; return NULL;
} }
prop= &geom->properties[geom->num_properties]; prop= &geom->properties[geom->num_properties];
prop->name= (char *)_XkbAlloc(strlen(name)+1); prop->name= strdup(name);
if (!prop->name) if (!prop->name)
return NULL; return NULL;
strcpy(prop->name,name); prop->value= strdup(value);
prop->value= (char *)_XkbAlloc(strlen(value)+1);
if (!prop->value) { if (!prop->value) {
_XkbFree(prop->name); _XkbFree(prop->name);
prop->name= NULL; prop->name= NULL;
return NULL; return NULL;
} }
strcpy(prop->value,value);
geom->num_properties++; geom->num_properties++;
return prop; return prop;
} }
...@@ -757,10 +753,9 @@ register XkbColorPtr color; ...@@ -757,10 +753,9 @@ register XkbColorPtr color;
} }
color= &geom->colors[geom->num_colors]; color= &geom->colors[geom->num_colors];
color->pixel= pixel; color->pixel= pixel;
color->spec= (char *)_XkbAlloc(strlen(spec)+1); color->spec= strdup(spec);
if (!color->spec) if (!color->spec)
return NULL; return NULL;
strcpy(color->spec,spec);
geom->num_colors++; geom->num_colors++;
return color; return color;
} }
......
...@@ -214,14 +214,12 @@ _XimOpenIM( ...@@ -214,14 +214,12 @@ _XimOpenIM(
im->core.res_name = NULL; im->core.res_name = NULL;
im->core.res_class = NULL; im->core.res_class = NULL;
if((res_name != NULL) && (*res_name != '\0')){ if((res_name != NULL) && (*res_name != '\0')){
if(!(im->core.res_name = (char *)Xmalloc(strlen(res_name)+1))) if(!(im->core.res_name = strdup(res_name)))
goto Error1; goto Error1;
strcpy(im->core.res_name,res_name);
} }
if((res_class != NULL) && (*res_class != '\0')){ if((res_class != NULL) && (*res_class != '\0')){
if(!(im->core.res_class = (char *)Xmalloc(strlen(res_class)+1))) if(!(im->core.res_class = strdup(res_class)))
goto Error2; goto Error2;
strcpy(im->core.res_class,res_class);
} }
if(!(im->core.im_name = _XimMakeImName(lcd))) if(!(im->core.im_name = _XimMakeImName(lcd)))
goto Error3; goto Error3;
......
...@@ -793,19 +793,15 @@ _XimEncodeString( ...@@ -793,19 +793,15 @@ _XimEncodeString(
XPointer top, XPointer top,
XPointer val) XPointer val)
{ {
int len;
char *string; char *string;
char **out; char **out;
if(val == (XPointer)NULL) { if(val == (XPointer)NULL) {
return False; return False;
} }
len = strlen((char *)val); if (!(string = strdup((char *)val))) {
if(!(string = (char *)Xmalloc(len + 1))) {
return False; return False;
} }
(void)strcpy(string, (char *)val);
string[len] = '\0';
out = (char **)((char *)top + info->offset); out = (char **)((char *)top + info->offset);
if(*out) { if(*out) {
...@@ -1163,21 +1159,18 @@ _XimDecodeString( ...@@ -1163,21 +1159,18 @@ _XimDecodeString(
XPointer top, XPointer top,
XPointer val) XPointer val)
{ {
int len = 0;
char *in; char *in;
char *string; char *string;
in = *((char **)((char *)top + info->offset)); in = *((char **)((char *)top + info->offset));
if(in != (char *)NULL) { if (in != NULL) {
len = strlen(in); string = strdup(in);
} else {
string = Xcalloc(1, 1); /* strdup("") */
} }
if(!(string = (char *)Xmalloc(len + 1))) { if (string == NULL) {
return False; return False;
} }
if(in != (char *)NULL) {
(void)strcpy(string, in);
}
string[len] = '\0';
*((char **)val) = string; *((char **)val) = string;
return True; return True;
} }
......
...@@ -290,7 +290,7 @@ _XimTransConf( ...@@ -290,7 +290,7 @@ _XimTransConf(
char *paddr; char *paddr;
TransSpecRec *spec; TransSpecRec *spec;
if (!(paddr = (char *)Xmalloc(strlen(address) + 1))) if (!(paddr = strdup(address)))
return False; return False;
if (!(spec = Xcalloc(1, sizeof(TransSpecRec)))) { if (!(spec = Xcalloc(1, sizeof(TransSpecRec)))) {
...@@ -298,7 +298,6 @@ _XimTransConf( ...@@ -298,7 +298,6 @@ _XimTransConf(
return False; return False;
} }
(void)strcpy(paddr, address);
spec->address = paddr; spec->address = paddr;
im->private.proto.spec = (XPointer)spec; im->private.proto.spec = (XPointer)spec;
......
...@@ -596,20 +596,18 @@ store_to_database( ...@@ -596,20 +596,18 @@ store_to_database(
goto err; goto err;
} }
new->category = (char *)Xmalloc(strlen(parse_info.category) + 1); new->category = strdup(parse_info.category);
if (new->category == NULL) { if (new->category == NULL) {
goto err; goto err;
} }
strcpy(new->category, parse_info.category);
if (! construct_name(name, sizeof(name))) { if (! construct_name(name, sizeof(name))) {
goto err; goto err;
} }
new->name = (char *)Xmalloc(strlen(name) + 1); new->name = strdup(name);
if (new->name == NULL) { if (new->name == NULL) {
goto err; goto err;
} }
strcpy(new->name, name);
new->next = *db; new->next = *db;
new->value = parse_info.value; new->value = parse_info.value;
new->value_num = parse_info.value_num; new->value_num = parse_info.value_num;
...@@ -943,10 +941,9 @@ f_default( ...@@ -943,10 +941,9 @@ f_default(
case S_NULL: case S_NULL:
if (parse_info.category != NULL) if (parse_info.category != NULL)
goto err; goto err;
p = (char *)Xmalloc(strlen(wordp) + 1); p = strdup(wordp);
if (p == NULL) if (p == NULL)
goto err; goto err;
strcpy(p, wordp);
parse_info.category = p; parse_info.category = p;
parse_info.pre_state = S_CATEGORY; parse_info.pre_state = S_CATEGORY;
break; break;
...@@ -960,10 +957,9 @@ f_default( ...@@ -960,10 +957,9 @@ f_default(
break; break;
} }
} }
p = (char *)Xmalloc(strlen(wordp) + 1); p = strdup(wordp);
if (p == NULL) if (p == NULL)
goto err; goto err;
strcpy(p, wordp);
if (parse_info.name[parse_info.nest_depth] != NULL) { if (parse_info.name[parse_info.nest_depth] != NULL) {
Xfree(parse_info.name[parse_info.nest_depth]); Xfree(parse_info.name[parse_info.nest_depth]);
} }
......
...@@ -401,10 +401,7 @@ resolve_name( ...@@ -401,10 +401,7 @@ resolve_name(
from = args[1], to = args[0]; /* right to left */ from = args[1], to = args[0]; /* right to left */
} }
if (! strcmp(from, lc_name)) { if (! strcmp(from, lc_name)) {
name = Xmalloc(strlen(to) + 1); name = strdup(to);
if (name != NULL) {
strcpy(name, to);
}
break; break;
} }
} }
...@@ -557,8 +554,7 @@ _XlcResolveLocaleName( ...@@ -557,8 +554,7 @@ _XlcResolveLocaleName(
if (name == NULL) { if (name == NULL) {
/* vendor locale name == Xlocale name, no expansion of alias */ /* vendor locale name == Xlocale name, no expansion of alias */
pub->siname = Xmalloc (strlen (lc_name) + 1); pub->siname = strdup (lc_name);
strcpy (pub->siname, lc_name);
} else { } else {
pub->siname = name; pub->siname = name;
} }
...@@ -707,8 +703,7 @@ _XlcLocaleDirName(char *dir_name, size_t dir_len, char *lc_name) ...@@ -707,8 +703,7 @@ _XlcLocaleDirName(char *dir_name, size_t dir_len, char *lc_name)
last_dir_len = strlen (dir_name) + 1; last_dir_len = strlen (dir_name) + 1;
last_dir_name = Xmalloc (last_dir_len); last_dir_name = Xmalloc (last_dir_len);
strcpy (last_dir_name, dir_name); strcpy (last_dir_name, dir_name);
last_lc_name = Xmalloc (strlen (lc_name) + 1); last_lc_name = strdup (lc_name);
strcpy (last_lc_name, lc_name);
return dir_name; return dir_name;
} }
...@@ -806,8 +801,7 @@ _XlcLocaleLibDirName(char *dir_name, size_t dir_len, char *lc_name) ...@@ -806,8 +801,7 @@ _XlcLocaleLibDirName(char *dir_name, size_t dir_len, char *lc_name)
last_dir_len = strlen (dir_name) + 1; last_dir_len = strlen (dir_name) + 1;
last_dir_name = Xmalloc (last_dir_len); last_dir_name = Xmalloc (last_dir_len);
strcpy (last_dir_name, dir_name); strcpy (last_dir_name, dir_name);
last_lc_name = Xmalloc (strlen (lc_name) + 1); last_lc_name = strdup (lc_name);
strcpy (last_lc_name, lc_name);
return dir_name; return dir_name;
} }
...@@ -215,10 +215,9 @@ add_parse_list( ...@@ -215,10 +215,9 @@ add_parse_list(
unsigned char ch; unsigned char ch;
int num; int num;
str = (char *) Xmalloc(strlen(encoding) + 1); str = strdup(encoding);
if (str == NULL) if (str == NULL)
return False; return False;
strcpy(str, encoding);
new = Xcalloc(1, sizeof(ParseInfoRec)); new = Xcalloc(1, sizeof(ParseInfoRec));
if (new == NULL) if (new == NULL)
...@@ -463,10 +462,9 @@ read_charset_define( ...@@ -463,10 +462,9 @@ read_charset_define(
break; break;
} }
if (new) { if (new) {
tmp = (char *)Xmalloc(strlen(cset_name)+1); tmp = strdup(cset_name);
if (tmp == NULL) if (tmp == NULL)
return; return;
strcpy(tmp,cset_name);
charsetd->name = tmp; charsetd->name = tmp;
} }
/* side */ /* side */
...@@ -522,8 +520,7 @@ read_charset_define( ...@@ -522,8 +520,7 @@ read_charset_define(
Xfree(charsetd->encoding_name); Xfree(charsetd->encoding_name);
} }
*/ */
tmp = (char *)Xmalloc(strlen(value[0])+1); tmp = strdup(value[0]);
strcpy(tmp,value[0]);
charsetd->encoding_name = tmp; charsetd->encoding_name = tmp;
charsetd->xrm_encoding_name = XrmStringToQuark(tmp); charsetd->xrm_encoding_name = XrmStringToQuark(tmp);
} }
...@@ -593,10 +590,9 @@ read_segmentconversion( ...@@ -593,10 +590,9 @@ read_segmentconversion(
if (num > 0) { if (num > 0) {
char *tmp; char *tmp;
_XlcDbg_printValue(name,value,num); _XlcDbg_printValue(name,value,num);
tmp = (char *)Xmalloc(strlen(value[0])+1); tmp = strdup(value[0]);
if (tmp == NULL) if (tmp == NULL)
return; return;
strcpy(tmp,value[0]);
conversion->source_encoding = tmp; conversion->source_encoding = tmp;
conversion->source = srch_charset_define(tmp,&new); conversion->source = srch_charset_define(tmp,&new);
} }
...@@ -606,10 +602,9 @@ read_segmentconversion( ...@@ -606,10 +602,9 @@ read_segmentconversion(
if (num > 0) { if (num > 0) {
char *tmp; char *tmp;
_XlcDbg_printValue(name,value,num); _XlcDbg_printValue(name,value,num);
tmp = (char *)Xmalloc(strlen(value[0])+1); tmp = strdup(value[0]);
if (tmp == NULL) if (tmp == NULL)
return; return;
strcpy(tmp,value[0]);
conversion->destination_encoding = tmp; conversion->destination_encoding = tmp;
conversion->dest = srch_charset_define(tmp,&new); conversion->dest = srch_charset_define(tmp,&new);
} }
...@@ -645,12 +640,11 @@ create_ctextseg( ...@@ -645,12 +640,11 @@ create_ctextseg(
ret = (ExtdSegment)Xmalloc(sizeof(ExtdSegmentRec)); ret = (ExtdSegment)Xmalloc(sizeof(ExtdSegmentRec));
if (ret == NULL) if (ret == NULL)
return NULL; return NULL;
ret->name = (char *)Xmalloc(strlen(value[0]) + 1); ret->name = strdup(value[0]);
if (ret->name == NULL) { if (ret->name == NULL) {
Xfree (ret); Xfree (ret);
return NULL; return NULL;
} }
strcpy(ret->name,value[0]);
cset_name = (char*) Xmalloc (strlen(ret->name) + 1); cset_name = (char*) Xmalloc (strlen(ret->name) + 1);
if (cset_name == NULL) { if (cset_name == NULL) {
Xfree (ret->name); Xfree (ret->name);
......
...@@ -128,10 +128,9 @@ load_public( ...@@ -128,10 +128,9 @@ load_public(
_XlcGetResource(lcd, "XLC_XLOCALE", "encoding_name", &values, &num); _XlcGetResource(lcd, "XLC_XLOCALE", "encoding_name", &values, &num);
str = (num > 0) ? values[0] : "STRING"; str = (num > 0) ? values[0] : "STRING";
pub->encoding_name = (char*) Xmalloc(strlen(str) + 1); pub->encoding_name = strdup(str);
if (pub->encoding_name == NULL) if (pub->encoding_name == NULL)
return False; return False;
strcpy(pub->encoding_name, str);
return True; return True;
} }
......
...@@ -523,9 +523,7 @@ get_font_name( ...@@ -523,9 +523,7 @@ get_font_name(
if (list == NULL) if (list == NULL)
return NULL; return NULL;
name = (char *) Xmalloc(strlen(*list) + 1); name = strdup(*list);
if (name)
strcpy(name, *list);
XFreeFontNames(list); XFreeFontNames(list);
...@@ -549,10 +547,9 @@ get_rotate_fontname( ...@@ -549,10 +547,9 @@ get_rotate_fontname(
|| len > XLFD_MAX_LEN) || len > XLFD_MAX_LEN)
return NULL; return NULL;
pattern = (char *)Xmalloc(len + 1); pattern = strdup(font_name);
if(!pattern) if(!pattern)
return NULL; return NULL;
strcpy(pattern, font_name);
memset(fields, 0, sizeof(char *) * 14); memset(fields, 0, sizeof(char *) * 14);
ptr = pattern; ptr = pattern;
...@@ -663,10 +660,8 @@ get_font_name_from_list( ...@@ -663,10 +660,8 @@ get_font_name_from_list(
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
fname = list[i]; fname = list[i];
if(is_match_charset(font_data, fname) == True) { if(is_match_charset(font_data, fname) == True) {
name = (char *) Xmalloc(strlen(fname) + 1); name = strdup(fname);
if (name) break;
strcpy(name, fname);
break;
} }
} }
...@@ -687,11 +682,10 @@ parse_all_name( ...@@ -687,11 +682,10 @@ parse_all_name(
if(is_match_charset(font_data, pattern) != True) if(is_match_charset(font_data, pattern) != True)
return False; return False;
font_data->xlfd_name = (char *)Xmalloc(strlen(pattern)+1); font_data->xlfd_name = strdup(pattern);
if(font_data->xlfd_name == NULL) if(font_data->xlfd_name == NULL)
return (-1); return (-1);
strcpy(font_data->xlfd_name, pattern);
return True; return True;
#else /* OLDCODE */ #else /* OLDCODE */
Display *dpy = oc->core.om->core.display; Display *dpy = oc->core.om->core.display;
...@@ -725,11 +719,10 @@ parse_all_name( ...@@ -725,11 +719,10 @@ parse_all_name(
} }
} }
font_data->xlfd_name = (char *)Xmalloc(strlen(pattern)+1); font_data->xlfd_name = strdup(pattern);
if(font_data->xlfd_name == NULL) if(font_data->xlfd_name == NULL)
return (-1); return (-1);
strcpy(font_data->xlfd_name, pattern);
return True; return True;
#endif /* OLDCODE */ #endif /* OLDCODE */
} }
...@@ -948,12 +941,9 @@ parse_fontdata( ...@@ -948,12 +941,9 @@ parse_fontdata(
* -- jjw/pma (HP) * -- jjw/pma (HP)
*/ */
if (font_data_return) { if (font_data_return) {
font_data_return->xlfd_name = (char *)Xmalloc font_data_return->xlfd_name = strdup(font_data->xlfd_name);
(strlen(font_data->xlfd_name) + 1);
if (!font_data_return->xlfd_name) return -1; if (!font_data_return->xlfd_name) return -1;
strcpy (font_data_return->xlfd_name, font_data->xlfd_name);
font_data_return->side = font_data->side; font_data_return->side = font_data->side;
} }
#ifdef FONTDEBUG #ifdef FONTDEBUG
...@@ -998,11 +988,9 @@ parse_fontdata( ...@@ -998,11 +988,9 @@ parse_fontdata(
#ifdef FONTDEBUG #ifdef FONTDEBUG
fprintf(stderr,"XLFD name: %s\n",font_data->xlfd_name); fprintf(stderr,"XLFD name: %s\n",font_data->xlfd_name);
#endif #endif
font_data_return->xlfd_name = (char *)Xmalloc font_data_return->xlfd_name = strdup(font_data->xlfd_name);
(strlen(font_data->xlfd_name) + 1);
if (!font_data_return->xlfd_name) return -1; if (!font_data_return->xlfd_name) return -1;
strcpy (font_data_return->xlfd_name, font_data->xlfd_name);
font_data_return->side = font_data->side; font_data_return->side = font_data->side;
} }
...@@ -1194,11 +1182,10 @@ parse_fontname( ...@@ -1194,11 +1182,10 @@ parse_fontname(
* be matched. It returns the required information in * be matched. It returns the required information in
* font_data_return. * font_data_return.
*/ */
font_set->font_name = (char *)Xmalloc font_set->font_name = strdup(font_data_return.xlfd_name);
(strlen(font_data_return.xlfd_name) + 1);
if(font_set->font_name == (char *) NULL) if(font_set->font_name == (char *) NULL)
goto err; goto err;
strcpy(font_set->font_name, font_data_return.xlfd_name);
font_set->side = font_data_return.side; font_set->side = font_data_return.side;
Xfree (font_data_return.xlfd_name); Xfree (font_data_return.xlfd_name);
...@@ -1225,11 +1212,10 @@ parse_fontname( ...@@ -1225,11 +1212,10 @@ parse_fontname(
break; break;
} }
} }
font_set->font_name = (char *)Xmalloc font_set->font_name = strdup(font_set->substitute[i].xlfd_name);
(strlen(font_set->substitute[i].xlfd_name) + 1);
if(font_set->font_name == (char *) NULL) if(font_set->font_name == (char *) NULL)
goto err; goto err;
strcpy(font_set->font_name,font_set->substitute[i].xlfd_name);
font_set->side = font_set->substitute[i].side; font_set->side = font_set->substitute[i].side;
if(parse_vw(oc, font_set, name_list, count) == -1) if(parse_vw(oc, font_set, name_list, count) == -1)
goto err; goto err;
...@@ -1239,11 +1225,10 @@ parse_fontname( ...@@ -1239,11 +1225,10 @@ parse_fontname(
} }
} }
base_name = (char *) Xmalloc(strlen(oc->core.base_name_list) + 1); base_name = strdup(oc->core.base_name_list);
if (base_name == NULL) if (base_name == NULL)
goto err; goto err;
strcpy(base_name, oc->core.base_name_list);
oc->core.base_name_list = base_name; oc->core.base_name_list = base_name;
XFreeStringList(name_list); XFreeStringList(name_list);
...@@ -1852,16 +1837,14 @@ create_om( ...@@ -1852,16 +1837,14 @@ create_om(
om->core.display = dpy; om->core.display = dpy;
om->core.rdb = rdb; om->core.rdb = rdb;
if (res_name) { if (res_name) {
om->core.res_name = (char *) Xmalloc(strlen(res_name) + 1); om->core.res_name = strdup(res_name);
if (om->core.res_name == NULL) if (om->core.res_name == NULL)
goto err; goto err;
strcpy(om->core.res_name, res_name);
} }
if (res_class) { if (res_class) {
om->core.res_class = (char *) Xmalloc(strlen(res_class) + 1); om->core.res_class = strdup(res_class);
if (om->core.res_class == NULL) if (om->core.res_class == NULL)
goto err; goto err;
strcpy(om->core.res_class, res_class);
} }
if (om_resources[0].xrm_name == NULLQUARK) if (om_resources[0].xrm_name == NULLQUARK)
...@@ -2014,10 +1997,9 @@ init_om( ...@@ -2014,10 +1997,9 @@ init_om(
_XlcGetResource(lcd, "XLC_FONTSET", "object_name", &value, &count); _XlcGetResource(lcd, "XLC_FONTSET", "object_name", &value, &count);
if (count > 0) { if (count > 0) {
gen->object_name = (char *) Xmalloc(strlen(*value) + 1); gen->object_name = strdup(*value);
if (gen->object_name == NULL) if (gen->object_name == NULL)
return False; return False;
strcpy(gen->object_name, *value);
} }
for (num = 0; ; num++) { for (num = 0; ; num++) {
......
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