summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2009-05-07 16:31:39 -0400
committerAdam Jackson <ajax@redhat.com>2009-05-07 16:31:39 -0400
commit33b839e16fe681ba915658f824ceb1b252084ea4 (patch)
tree5e831dec53ce9197d733d6b1f21713d51f75f039
parent4f8dd1aa10a36700bf1f2b05931cd29151b9fee4 (diff)
s/_XkbDupString/strdup/
Super special bonus lols edition: _XkbDupString would allocate the new string with calloc, just to be extra sure.
-rw-r--r--src/XKBfileInt.h5
-rw-r--r--src/maprules.c50
-rw-r--r--src/xkbconfig.c6
-rw-r--r--src/xkmread.c23
4 files changed, 34 insertions, 50 deletions
diff --git a/src/XKBfileInt.h b/src/XKBfileInt.h
index 7eb81a0..5573638 100644
--- a/src/XKBfileInt.h
+++ b/src/XKBfileInt.h
@@ -30,6 +30,7 @@
/* $XFree86$ */
#include "XKBfile.h"
+#include <string.h>
#ifdef DEBUG
#define _XkbLibError(c,l,d) \
@@ -64,10 +65,6 @@
_XFUNCPROTOBEGIN
-extern char * _XkbDupString(
- char * /* old_str */
-);
-
#define _XkbStrCaseEqual(s1,s2) (_XkbStrCaseCmp(s1,s2)==0)
#ifdef NEED_STRCASECMP
diff --git a/src/maprules.c b/src/maprules.c
index 6060a03..cfc4d6d 100644
--- a/src/maprules.c
+++ b/src/maprules.c
@@ -439,8 +439,8 @@ Bool append = False;
}
if (*words == '\0')
return False;
- group->name = _XkbDupString(gname);
- group->words = _XkbDupString(words);
+ group->name = strdup(gname);
+ group->words = strdup(words);
for (i = 1, words = group->words; *words; words++) {
if ( *words == ' ') {
*words++ = '\0';
@@ -491,17 +491,17 @@ Bool append = False;
rule->flags|= XkbRF_Append;
else
rule->flags|= XkbRF_Normal;
- rule->model= _XkbDupString(tmp.name[MODEL]);
- rule->layout= _XkbDupString(tmp.name[LAYOUT]);
- rule->variant= _XkbDupString(tmp.name[VARIANT]);
- rule->option= _XkbDupString(tmp.name[OPTION]);
-
- rule->keycodes= _XkbDupString(tmp.name[KEYCODES]);
- rule->symbols= _XkbDupString(tmp.name[SYMBOLS]);
- rule->types= _XkbDupString(tmp.name[TYPES]);
- rule->compat= _XkbDupString(tmp.name[COMPAT]);
- rule->geometry= _XkbDupString(tmp.name[GEOMETRY]);
- rule->keymap= _XkbDupString(tmp.name[KEYMAP]);
+ rule->model= strdup(tmp.name[MODEL]);
+ rule->layout= strdup(tmp.name[LAYOUT]);
+ rule->variant= strdup(tmp.name[VARIANT]);
+ rule->option= strdup(tmp.name[OPTION]);
+
+ rule->keycodes= strdup(tmp.name[KEYCODES]);
+ rule->symbols= strdup(tmp.name[SYMBOLS]);
+ rule->types= strdup(tmp.name[TYPES]);
+ rule->compat= strdup(tmp.name[COMPAT]);
+ rule->geometry= strdup(tmp.name[GEOMETRY]);
+ rule->keymap= strdup(tmp.name[KEYMAP]);
rule->layout_num = rule->variant_num = 0;
for (i = 0; i < nread; i++) {
@@ -546,7 +546,7 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
bzero((char *)mdefs,sizeof(XkbRF_MultiDefsRec));
mdefs->model = defs->model;
- mdefs->options = _XkbDupString(defs->options);
+ mdefs->options = strdup(defs->options);
if (mdefs->options) squeeze_spaces(mdefs->options);
if (defs->layout) {
@@ -555,7 +555,7 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
} else {
char *p;
int i;
- mdefs->layout[1] = _XkbDupString(defs->layout);
+ mdefs->layout[1] = strdup(defs->layout);
if (mdefs->layout[1] == NULL)
return False;
squeeze_spaces(mdefs->layout[1]);
@@ -579,7 +579,7 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
} else {
char *p;
int i;
- mdefs->variant[1] = _XkbDupString(defs->variant);
+ mdefs->variant[1] = strdup(defs->variant);
if (mdefs->variant[1] == NULL)
return False;
squeeze_spaces(mdefs->variant[1]);
@@ -615,7 +615,7 @@ Apply(char *src, char **dst)
*dst= _Concat(*dst, src);
} else {
if (*dst == NULL)
- *dst= _XkbDupString(src);
+ *dst= strdup(src);
}
}
}
@@ -1059,8 +1059,8 @@ XkbRF_AddVarDescCopy(XkbRF_DescribeVarsPtr vars,XkbRF_VarDescPtr from)
XkbRF_VarDescPtr nd;
if ((nd=XkbRF_AddVarDesc(vars))!=NULL) {
- nd->name= _XkbDupString(from->name);
- nd->desc= _XkbDupString(from->desc);
+ nd->name= strdup(from->name);
+ nd->desc= strdup(from->desc);
}
return nd;
}
@@ -1088,7 +1088,7 @@ XkbRF_AddVarToDescribe(XkbRF_RulesPtr rules,char *name)
rules->extra= NULL;
return NULL;
}
- rules->extra_names[rules->num_extra]= _XkbDupString(name);
+ rules->extra_names[rules->num_extra]= strdup(name);
bzero(&rules->extra[rules->num_extra],sizeof(XkbRF_DescribeVarsRec));
return &rules->extra[rules->num_extra++];
}
@@ -1379,30 +1379,30 @@ Status rtrn;
out=(char*)data;
end=out+nitems;
if (out && (*out) && rf_rtrn)
- *rf_rtrn= _XkbDupString(out);
+ *rf_rtrn= strdup(out);
out+=strlen(out)+1;
if (out<end) {
if (*out)
- vd_rtrn->model= _XkbDupString(out);
+ vd_rtrn->model= strdup(out);
out+=strlen(out)+1;
}
if (out<end) {
if (*out)
- vd_rtrn->layout= _XkbDupString(out);
+ vd_rtrn->layout= strdup(out);
out+=strlen(out)+1;
}
if (out<end) {
if (*out)
- vd_rtrn->variant= _XkbDupString(out);
+ vd_rtrn->variant= strdup(out);
out+=strlen(out)+1;
}
if (out<end) {
if (*out)
- vd_rtrn->options= _XkbDupString(out);
+ vd_rtrn->options= strdup(out);
out+=strlen(out)+1;
}
diff --git a/src/xkbconfig.c b/src/xkbconfig.c
index 37272ce..dd04e81 100644
--- a/src/xkbconfig.c
+++ b/src/xkbconfig.c
@@ -377,7 +377,7 @@ XkbCFAddModByName( XkbConfigRtrnPtr rtrn,
last->merge= merge;
last->name= NULL;
}
- last->name= _XkbDupString(name);
+ last->name= strdup(name);
}
return last;
}
@@ -501,7 +501,7 @@ unsigned what;
}
if (*str!=NULL)
_XkbFree(*str);
- *str= _XkbDupString(val.str);
+ *str= strdup(val.str);
break;
case _XkbCF_InitialMods:
case _XkbCF_IgnoreLockMods:
@@ -1060,7 +1060,7 @@ DefaultFinish( XkbConfigFieldsPtr fields,
return DefaultCleanUp(rtrn);
if (what==XkbCF_Check) {
if ((rtrn->symbols==NULL)&&(rtrn->phys_symbols!=NULL))
- rtrn->symbols= _XkbDupString(rtrn->phys_symbols);
+ rtrn->symbols= strdup(rtrn->phys_symbols);
}
if ((what==XkbCF_Apply)||(what==XkbCF_Check)) {
if (xkb && xkb->names && (rtrn->num_unbound_mods>0))
diff --git a/src/xkmread.c b/src/xkmread.c
index 91bfa7b..b746ce8 100644
--- a/src/xkmread.c
+++ b/src/xkmread.c
@@ -76,19 +76,6 @@ XkbInternAtom(Display *dpy,char *str,Bool only_if_exists)
#define SEEK_SET 0
#endif
-char *
-_XkbDupString(char *str)
-{
-char *new;
-
- if (str==NULL)
- return NULL;
- new= (char *)_XkbCalloc(strlen(str)+1,sizeof(char));
- if (new)
- strcpy(new,str);
- return new;
-}
-
/***====================================================================***/
static XPointer
@@ -792,9 +779,9 @@ int nRead=0;
doodad->text.height= doodadWire.text.height;
doodad->text.color_ndx= doodadWire.text.color_ndx;
nRead+= XkmGetCountedString(file,buf,100);
- doodad->text.text= _XkbDupString(buf);
+ doodad->text.text= strdup(buf);
nRead+= XkmGetCountedString(file,buf,100);
- doodad->text.font= _XkbDupString(buf);
+ doodad->text.font= strdup(buf);
break;
case XkbIndicatorDoodad:
doodad->indicator.shape_ndx= doodadWire.indicator.shape_ndx;
@@ -806,7 +793,7 @@ int nRead=0;
doodad->logo.color_ndx= doodadWire.logo.color_ndx;
doodad->logo.shape_ndx= doodadWire.logo.shape_ndx;
nRead+= XkmGetCountedString(file,buf,100);
- doodad->logo.logo_name= _XkbDupString(buf);
+ doodad->logo.logo_name= strdup(buf);
break;
default:
/* report error? */
@@ -970,7 +957,7 @@ XkbGeometrySizesRec sizes;
geom->width_mm= wireGeom.width_mm;
geom->height_mm= wireGeom.height_mm;
nRead+= XkmGetCountedString(file,buf,100);
- geom->label_font= _XkbDupString(buf);
+ geom->label_font= strdup(buf);
if (wireGeom.num_properties>0) {
char val[1024];
for (i=0;i<wireGeom.num_properties;i++) {
@@ -1226,7 +1213,7 @@ char name[100];
return NULL;
}
if (XkmGetCountedString(file,name,100)>0)
- return _XkbDupString(name);
+ return strdup(name);
break;
default:
_XkbLibError(_XkbErrBadImplementation,