summaryrefslogtreecommitdiff
path: root/xkb
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2011-02-13 21:36:03 -0800
committerPeter Hutterer <peter.hutterer@who-t.net>2011-02-15 10:35:41 +1000
commitaac1b435664819008989ed19f73e9c89920602c5 (patch)
treeda97dfec6fe635ec8cd609ee03ad247a07b3e499 /xkb
parenta4a2e814d5d0e6152307a301eda1d6fc1c555aaa (diff)
Replace _XkbDupString with Xstrdup
The two functions have identical semantics, including safely returning NULL when NULL is passed in (which POSIX strdup does not guarantee). Some callers could probably be adjusted to call libc strdup directly, when we know the input is non-NULL. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Diffstat (limited to 'xkb')
-rw-r--r--xkb/maprules.c30
-rw-r--r--xkb/xkb.c8
-rw-r--r--xkb/xkbInit.c20
-rw-r--r--xkb/xkbfmisc.c10
-rw-r--r--xkb/xkmread.c21
5 files changed, 38 insertions, 51 deletions
diff --git a/xkb/maprules.c b/xkb/maprules.c
index 0c91cdc20..f94089982 100644
--- a/xkb/maprules.c
+++ b/xkb/maprules.c
@@ -391,8 +391,8 @@ Bool append = FALSE;
}
if (*words == '\0')
return FALSE;
- group->name = _XkbDupString(gname);
- group->words = _XkbDupString(words);
+ group->name = Xstrdup(gname);
+ group->words = Xstrdup(words);
for (i = 1, words = group->words; *words; words++) {
if ( *words == ' ') {
*words++ = '\0';
@@ -443,16 +443,16 @@ 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->model= Xstrdup(tmp.name[MODEL]);
+ rule->layout= Xstrdup(tmp.name[LAYOUT]);
+ rule->variant= Xstrdup(tmp.name[VARIANT]);
+ rule->option= Xstrdup(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->keycodes= Xstrdup(tmp.name[KEYCODES]);
+ rule->symbols= Xstrdup(tmp.name[SYMBOLS]);
+ rule->types= Xstrdup(tmp.name[TYPES]);
+ rule->compat= Xstrdup(tmp.name[COMPAT]);
+ rule->geometry= Xstrdup(tmp.name[GEOMETRY]);
rule->layout_num = rule->variant_num = 0;
for (i = 0; i < nread; i++) {
@@ -497,7 +497,7 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
memset((char *)mdefs, 0, sizeof(XkbRF_MultiDefsRec));
mdefs->model = defs->model;
- mdefs->options = _XkbDupString(defs->options);
+ mdefs->options = Xstrdup(defs->options);
if (mdefs->options) squeeze_spaces(mdefs->options);
if (defs->layout) {
@@ -506,7 +506,7 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
} else {
char *p;
int i;
- mdefs->layout[1] = _XkbDupString(defs->layout);
+ mdefs->layout[1] = Xstrdup(defs->layout);
if (mdefs->layout[1] == NULL)
return FALSE;
squeeze_spaces(mdefs->layout[1]);
@@ -530,7 +530,7 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
} else {
char *p;
int i;
- mdefs->variant[1] = _XkbDupString(defs->variant);
+ mdefs->variant[1] = Xstrdup(defs->variant);
if (mdefs->variant[1] == NULL)
return FALSE;
squeeze_spaces(mdefs->variant[1]);
@@ -566,7 +566,7 @@ Apply(char *src, char **dst)
*dst= _Concat(*dst, src);
} else {
if (*dst == NULL)
- *dst= _XkbDupString(src);
+ *dst= Xstrdup(src);
}
}
}
diff --git a/xkb/xkb.c b/xkb/xkb.c
index 6fd66c5e5..d98e35296 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -5619,17 +5619,17 @@ ProcXkbGetKbdByName(ClientPtr client)
else fwant= stuff->want|stuff->need;
if ((!names.compat)&&
(fwant&(XkbGBN_CompatMapMask|XkbGBN_IndicatorMapMask))) {
- names.compat= _XkbDupString("%");
+ names.compat= Xstrdup("%");
}
if ((!names.types)&&(fwant&(XkbGBN_TypesMask))) {
- names.types= _XkbDupString("%");
+ names.types= Xstrdup("%");
}
if ((!names.symbols)&&(fwant&XkbGBN_SymbolsMask)) {
- names.symbols= _XkbDupString("%");
+ names.symbols= Xstrdup("%");
}
geom_changed= ((names.geometry!=NULL)&&(strcmp(names.geometry,"%")!=0));
if ((!names.geometry)&&(fwant&XkbGBN_GeometryMask)) {
- names.geometry= _XkbDupString("%");
+ names.geometry= Xstrdup("%");
geom_changed= FALSE;
}
diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c
index fbf8f14b8..3d3febb4f 100644
--- a/xkb/xkbInit.c
+++ b/xkb/xkbInit.c
@@ -221,15 +221,15 @@ static void
XkbSetRulesUsed(XkbRMLVOSet *rmlvo)
{
free(XkbRulesUsed);
- XkbRulesUsed= (rmlvo->rules?_XkbDupString(rmlvo->rules):NULL);
+ XkbRulesUsed= (rmlvo->rules?Xstrdup(rmlvo->rules):NULL);
free(XkbModelUsed);
- XkbModelUsed= (rmlvo->model?_XkbDupString(rmlvo->model):NULL);
+ XkbModelUsed= (rmlvo->model?Xstrdup(rmlvo->model):NULL);
free(XkbLayoutUsed);
- XkbLayoutUsed= (rmlvo->layout?_XkbDupString(rmlvo->layout):NULL);
+ XkbLayoutUsed= (rmlvo->layout?Xstrdup(rmlvo->layout):NULL);
free(XkbVariantUsed);
- XkbVariantUsed= (rmlvo->variant?_XkbDupString(rmlvo->variant):NULL);
+ XkbVariantUsed= (rmlvo->variant?Xstrdup(rmlvo->variant):NULL);
free(XkbOptionsUsed);
- XkbOptionsUsed= (rmlvo->options?_XkbDupString(rmlvo->options):NULL);
+ XkbOptionsUsed= (rmlvo->options?Xstrdup(rmlvo->options):NULL);
if (XkbWantRulesProp)
QueueWorkProc(XkbWriteRulesProp,NULL,NULL);
return;
@@ -240,23 +240,23 @@ XkbSetRulesDflts(XkbRMLVOSet *rmlvo)
{
if (rmlvo->rules) {
free(XkbRulesDflt);
- XkbRulesDflt= _XkbDupString(rmlvo->rules);
+ XkbRulesDflt= Xstrdup(rmlvo->rules);
}
if (rmlvo->model) {
free(XkbModelDflt);
- XkbModelDflt= _XkbDupString(rmlvo->model);
+ XkbModelDflt= Xstrdup(rmlvo->model);
}
if (rmlvo->layout) {
free(XkbLayoutDflt);
- XkbLayoutDflt= _XkbDupString(rmlvo->layout);
+ XkbLayoutDflt= Xstrdup(rmlvo->layout);
}
if (rmlvo->variant) {
free(XkbVariantDflt);
- XkbVariantDflt= _XkbDupString(rmlvo->variant);
+ XkbVariantDflt= Xstrdup(rmlvo->variant);
}
if (rmlvo->options) {
free(XkbOptionsDflt);
- XkbOptionsDflt= _XkbDupString(rmlvo->options);
+ XkbOptionsDflt= Xstrdup(rmlvo->options);
}
return;
}
diff --git a/xkb/xkbfmisc.c b/xkb/xkbfmisc.c
index 7aa9863f2..dea347335 100644
--- a/xkb/xkbfmisc.c
+++ b/xkb/xkbfmisc.c
@@ -241,7 +241,7 @@ unsigned wantNames,wantConfig,wantDflts;
if (wantNames&XkmTypesMask) {
if (old_names->types!=None) {
tmp= NameForAtom(old_names->types);
- names->types= _XkbDupString(tmp);
+ names->types= Xstrdup(tmp);
}
else {
wantDflts|= XkmTypesMask;
@@ -251,7 +251,7 @@ unsigned wantNames,wantConfig,wantDflts;
if (wantNames&XkmCompatMapMask) {
if (old_names->compat!=None) {
tmp= NameForAtom(old_names->compat);
- names->compat= _XkbDupString(tmp);
+ names->compat= Xstrdup(tmp);
}
else wantDflts|= XkmCompatMapMask;
complete|= XkmCompatMapMask;
@@ -260,13 +260,13 @@ unsigned wantNames,wantConfig,wantDflts;
if (old_names->symbols==None)
return FALSE;
tmp= NameForAtom(old_names->symbols);
- names->symbols= _XkbDupString(tmp);
+ names->symbols= Xstrdup(tmp);
complete|= XkmSymbolsMask;
}
if (wantNames&XkmKeyNamesMask) {
if (old_names->keycodes!=None) {
tmp= NameForAtom(old_names->keycodes);
- names->keycodes= _XkbDupString(tmp);
+ names->keycodes= Xstrdup(tmp);
}
else wantDflts|= XkmKeyNamesMask;
complete|= XkmKeyNamesMask;
@@ -275,7 +275,7 @@ unsigned wantNames,wantConfig,wantDflts;
if (old_names->geometry==None)
return FALSE;
tmp= NameForAtom(old_names->geometry);
- names->geometry= _XkbDupString(tmp);
+ names->geometry= Xstrdup(tmp);
complete|= XkmGeometryMask;
wantNames&= ~XkmGeometryMask;
}
diff --git a/xkb/xkmread.c b/xkb/xkmread.c
index b564195bc..e8b97dcda 100644
--- a/xkb/xkmread.c
+++ b/xkb/xkmread.c
@@ -51,19 +51,6 @@ XkbInternAtom(char *str,Bool only_if_exists)
return MakeAtom(str,strlen(str),!only_if_exists);
}
-char *
-_XkbDupString(const char *str)
-{
-char *new;
-
- if (str==NULL)
- return NULL;
- new= calloc(strlen(str)+1,sizeof(char));
- if (new)
- strcpy(new,str);
- return new;
-}
-
/***====================================================================***/
static void *
@@ -845,9 +832,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= Xstrdup(buf);
nRead+= XkmGetCountedString(file,buf,100);
- doodad->text.font= _XkbDupString(buf);
+ doodad->text.font= Xstrdup(buf);
break;
case XkbIndicatorDoodad:
doodad->indicator.shape_ndx= doodadWire.indicator.shape_ndx;
@@ -859,7 +846,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= Xstrdup(buf);
break;
default:
/* report error? */
@@ -1021,7 +1008,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= Xstrdup(buf);
if (wireGeom.num_properties>0) {
char val[1024];
for (i=0;i<wireGeom.num_properties;i++) {