aboutsummaryrefslogtreecommitdiff
path: root/nx-X11
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2011-02-13 21:36:03 -0800
committerUlrich Sibiller <uli42@gmx.de>2017-03-03 21:33:34 +0100
commitbdfb52193b5a2c5e44969b11d997ce19f0310af9 (patch)
tree7f2b93218eddb984f5ae27e0aa086393e184476c /nx-X11
parente61e9795c3d19b163ebea9a230c2acc718a70d79 (diff)
downloadnx-libs-bdfb52193b5a2c5e44969b11d997ce19f0310af9.tar.gz
nx-libs-bdfb52193b5a2c5e44969b11d997ce19f0310af9.tar.bz2
nx-libs-bdfb52193b5a2c5e44969b11d997ce19f0310af9.zip
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> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
Diffstat (limited to 'nx-X11')
-rw-r--r--nx-X11/programs/Xserver/include/xkbsrv.h4
-rw-r--r--nx-X11/programs/Xserver/xkb/ddxConfig.c2
-rw-r--r--nx-X11/programs/Xserver/xkb/ddxLoad.c4
-rw-r--r--nx-X11/programs/Xserver/xkb/maprules.c40
-rw-r--r--nx-X11/programs/Xserver/xkb/xkb.c8
-rw-r--r--nx-X11/programs/Xserver/xkb/xkbInit.c30
-rw-r--r--nx-X11/programs/Xserver/xkb/xkbconfig.c6
-rw-r--r--nx-X11/programs/Xserver/xkb/xkbfmisc.c10
-rw-r--r--nx-X11/programs/Xserver/xkb/xkmread.c23
9 files changed, 55 insertions, 72 deletions
diff --git a/nx-X11/programs/Xserver/include/xkbsrv.h b/nx-X11/programs/Xserver/include/xkbsrv.h
index f0f803370..d5036b6fd 100644
--- a/nx-X11/programs/Xserver/include/xkbsrv.h
+++ b/nx-X11/programs/Xserver/include/xkbsrv.h
@@ -985,10 +985,6 @@ extern XkbGeometryPtr XkbLookupNamedGeometry(
Bool * /* shouldFree */
);
-extern char * _XkbDupString(
- char * /* str */
-);
-
extern void XkbConvertCase(
KeySym /* sym */,
KeySym * /* lower */,
diff --git a/nx-X11/programs/Xserver/xkb/ddxConfig.c b/nx-X11/programs/Xserver/xkb/ddxConfig.c
index 2fd5e7610..0046b853e 100644
--- a/nx-X11/programs/Xserver/xkb/ddxConfig.c
+++ b/nx-X11/programs/Xserver/xkb/ddxConfig.c
@@ -187,7 +187,7 @@ XkbConfigRtrnPtr rtrn;
}
if (rtrn->symbols!=NULL) {
if (rtrn->phys_symbols==NULL)
- rtrn->phys_symbols= _XkbDupString(names->symbols);
+ rtrn->phys_symbols= Xstrdup(names->symbols);
if (names->symbols) _XkbFree(names->symbols);
names->symbols= rtrn->symbols;
rtrn->symbols= NULL;
diff --git a/nx-X11/programs/Xserver/xkb/ddxLoad.c b/nx-X11/programs/Xserver/xkb/ddxLoad.c
index 4934d266c..5f24e9ccc 100644
--- a/nx-X11/programs/Xserver/xkb/ddxLoad.c
+++ b/nx-X11/programs/Xserver/xkb/ddxLoad.c
@@ -542,8 +542,8 @@ char *cmd = NULL,file[PATH_MAX],xkm_output_dir[PATH_MAX],*map,*outFile;
}
}
if ((outFile= strrchr(file,'/'))!=NULL)
- outFile= _XkbDupString(&outFile[1]);
- else outFile= _XkbDupString(file);
+ outFile= Xstrdup(&outFile[1]);
+ else outFile= Xstrdup(file);
XkbEnsureSafeMapName(outFile);
OutputDirectory(xkm_output_dir, sizeof(xkm_output_dir));
diff --git a/nx-X11/programs/Xserver/xkb/maprules.c b/nx-X11/programs/Xserver/xkb/maprules.c
index c89cc528a..337c8634b 100644
--- a/nx-X11/programs/Xserver/xkb/maprules.c
+++ b/nx-X11/programs/Xserver/xkb/maprules.c
@@ -426,8 +426,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';
@@ -478,17 +478,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= Xstrdup(tmp.name[MODEL]);
+ rule->layout= Xstrdup(tmp.name[LAYOUT]);
+ rule->variant= Xstrdup(tmp.name[VARIANT]);
+ rule->option= Xstrdup(tmp.name[OPTION]);
+
+ 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->keymap= Xstrdup(tmp.name[KEYMAP]);
rule->layout_num = rule->variant_num = 0;
for (i = 0; i < nread; i++) {
@@ -533,7 +533,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 = Xstrdup(defs->options);
if (mdefs->options) squeeze_spaces(mdefs->options);
if (defs->layout) {
@@ -542,7 +542,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]);
@@ -566,7 +566,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]);
@@ -602,7 +602,7 @@ Apply(char *src, char **dst)
*dst= _Concat(*dst, src);
} else {
if (*dst == NULL)
- *dst= _XkbDupString(src);
+ *dst= Xstrdup(src);
}
}
}
@@ -1045,8 +1045,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= Xstrdup(from->name);
+ nd->desc= Xstrdup(from->desc);
}
return nd;
}
@@ -1074,7 +1074,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]= Xstrdup(name);
bzero(&rules->extra[rules->num_extra],sizeof(XkbRF_DescribeVarsRec));
return &rules->extra[rules->num_extra++];
}
diff --git a/nx-X11/programs/Xserver/xkb/xkb.c b/nx-X11/programs/Xserver/xkb/xkb.c
index 47f4a2f96..b41548b83 100644
--- a/nx-X11/programs/Xserver/xkb/xkb.c
+++ b/nx-X11/programs/Xserver/xkb/xkb.c
@@ -5164,17 +5164,17 @@ ProcXkbGetKbdByName(ClientPtr client)
if (!names.keymap) {
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/nx-X11/programs/Xserver/xkb/xkbInit.c b/nx-X11/programs/Xserver/xkb/xkbInit.c
index 1f4bc34b4..962fb4456 100644
--- a/nx-X11/programs/Xserver/xkb/xkbInit.c
+++ b/nx-X11/programs/Xserver/xkb/xkbInit.c
@@ -229,16 +229,16 @@ XkbSetRulesUsed(XkbRF_VarDefsPtr defs)
{
if (XkbModelUsed)
_XkbFree(XkbModelUsed);
- XkbModelUsed= (defs->model?_XkbDupString(defs->model):NULL);
+ XkbModelUsed= (defs->model?Xstrdup(defs->model):NULL);
if (XkbLayoutUsed)
_XkbFree(XkbLayoutUsed);
- XkbLayoutUsed= (defs->layout?_XkbDupString(defs->layout):NULL);
+ XkbLayoutUsed= (defs->layout?Xstrdup(defs->layout):NULL);
if (XkbVariantUsed)
_XkbFree(XkbVariantUsed);
- XkbVariantUsed= (defs->variant?_XkbDupString(defs->variant):NULL);
+ XkbVariantUsed= (defs->variant?Xstrdup(defs->variant):NULL);
if (XkbOptionsUsed)
_XkbFree(XkbOptionsUsed);
- XkbOptionsUsed= (defs->options?_XkbDupString(defs->options):NULL);
+ XkbOptionsUsed= (defs->options?Xstrdup(defs->options):NULL);
if (XkbWantRulesProp)
QueueWorkProc(XkbWriteRulesProp,NULL,NULL);
return;
@@ -250,27 +250,27 @@ XkbSetRulesDflts(char *rulesFile,char *model,char *layout,
{
if (XkbRulesFile)
_XkbFree(XkbRulesFile);
- XkbRulesFile= _XkbDupString(rulesFile);
+ XkbRulesFile= Xstrdup(rulesFile);
rulesDefined= True;
if (model) {
if (XkbModelDflt)
_XkbFree(XkbModelDflt);
- XkbModelDflt= _XkbDupString(model);
+ XkbModelDflt= Xstrdup(model);
}
if (layout) {
if (XkbLayoutDflt)
_XkbFree(XkbLayoutDflt);
- XkbLayoutDflt= _XkbDupString(layout);
+ XkbLayoutDflt= Xstrdup(layout);
}
if (variant) {
if (XkbVariantDflt)
_XkbFree(XkbVariantDflt);
- XkbVariantDflt= _XkbDupString(variant);
+ XkbVariantDflt= Xstrdup(variant);
}
if (options) {
if (XkbOptionsDflt)
_XkbFree(XkbOptionsDflt);
- XkbOptionsDflt= _XkbDupString(options);
+ XkbOptionsDflt= Xstrdup(options);
}
return;
}
@@ -637,12 +637,12 @@ XkbRF_VarDefsRec defs;
* generation. Eventually they will be freed at the end of this
* function.
*/
- if (names->keymap) names->keymap = _XkbDupString(names->keymap);
- if (names->keycodes) names->keycodes = _XkbDupString(names->keycodes);
- if (names->types) names->types = _XkbDupString(names->types);
- if (names->compat) names->compat = _XkbDupString(names->compat);
- if (names->geometry) names->geometry = _XkbDupString(names->geometry);
- if (names->symbols) names->symbols = _XkbDupString(names->symbols);
+ if (names->keymap) names->keymap = Xstrdup(names->keymap);
+ if (names->keycodes) names->keycodes = Xstrdup(names->keycodes);
+ if (names->types) names->types = Xstrdup(names->types);
+ if (names->compat) names->compat = Xstrdup(names->compat);
+ if (names->geometry) names->geometry = Xstrdup(names->geometry);
+ if (names->symbols) names->symbols = Xstrdup(names->symbols);
if (defs.model && defs.layout && rules) {
XkbComponentNamesRec rNames;
diff --git a/nx-X11/programs/Xserver/xkb/xkbconfig.c b/nx-X11/programs/Xserver/xkb/xkbconfig.c
index de138ef45..5fcd594bc 100644
--- a/nx-X11/programs/Xserver/xkb/xkbconfig.c
+++ b/nx-X11/programs/Xserver/xkb/xkbconfig.c
@@ -363,7 +363,7 @@ XkbCFAddModByName( XkbConfigRtrnPtr rtrn,
last->merge= merge;
last->name= NULL;
}
- last->name= _XkbDupString(name);
+ last->name= Xstrdup(name);
}
return last;
}
@@ -487,7 +487,7 @@ unsigned what;
}
if (*str!=NULL)
_XkbFree(*str);
- *str= _XkbDupString(val.str);
+ *str= Xstrdup(val.str);
break;
case _XkbCF_InitialMods:
case _XkbCF_IgnoreLockMods:
@@ -1046,7 +1046,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= Xstrdup(rtrn->phys_symbols);
}
if ((what==XkbCF_Apply)||(what==XkbCF_Check)) {
if (xkb && xkb->names && (rtrn->num_unbound_mods>0))
diff --git a/nx-X11/programs/Xserver/xkb/xkbfmisc.c b/nx-X11/programs/Xserver/xkb/xkbfmisc.c
index 43d55aa47..3f5a57e93 100644
--- a/nx-X11/programs/Xserver/xkb/xkbfmisc.c
+++ b/nx-X11/programs/Xserver/xkb/xkbfmisc.c
@@ -334,7 +334,7 @@ XkbFileInfo finfo;
if (wantNames&XkmTypesMask) {
if (old_names->types!=None) {
tmp= XkbAtomGetString(dpy,old_names->types);
- names->types= _XkbDupString(tmp);
+ names->types= Xstrdup(tmp);
}
else {
wantDflts|= XkmTypesMask;
@@ -344,7 +344,7 @@ XkbFileInfo finfo;
if (wantNames&XkmCompatMapMask) {
if (old_names->compat!=None) {
tmp= XkbAtomGetString(dpy,old_names->compat);
- names->compat= _XkbDupString(tmp);
+ names->compat= Xstrdup(tmp);
}
else wantDflts|= XkmCompatMapMask;
complete|= XkmCompatMapMask;
@@ -353,13 +353,13 @@ XkbFileInfo finfo;
if (old_names->symbols==None)
return False;
tmp= XkbAtomGetString(dpy,old_names->symbols);
- names->symbols= _XkbDupString(tmp);
+ names->symbols= Xstrdup(tmp);
complete|= XkmSymbolsMask;
}
if (wantNames&XkmKeyNamesMask) {
if (old_names->keycodes!=None) {
tmp= XkbAtomGetString(dpy,old_names->keycodes);
- names->keycodes= _XkbDupString(tmp);
+ names->keycodes= Xstrdup(tmp);
}
else wantDflts|= XkmKeyNamesMask;
complete|= XkmKeyNamesMask;
@@ -368,7 +368,7 @@ XkbFileInfo finfo;
if (old_names->geometry==None)
return False;
tmp= XkbAtomGetString(dpy,old_names->geometry);
- names->geometry= _XkbDupString(tmp);
+ names->geometry= Xstrdup(tmp);
complete|= XkmGeometryMask;
wantNames&= ~XkmGeometryMask;
}
diff --git a/nx-X11/programs/Xserver/xkb/xkmread.c b/nx-X11/programs/Xserver/xkb/xkmread.c
index 1d8f6d772..71b65a4c0 100644
--- a/nx-X11/programs/Xserver/xkb/xkmread.c
+++ b/nx-X11/programs/Xserver/xkb/xkmread.c
@@ -58,19 +58,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
@@ -774,9 +761,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;
@@ -788,7 +775,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? */
@@ -952,7 +939,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++) {
@@ -1211,7 +1198,7 @@ char name[100];
return 0;
}
if (XkmGetCountedString(file,name,100)>0)
- return _XkbDupString(name);
+ return Xstrdup(name);
break;
default:
_XkbLibError(_XkbErrBadImplementation,