if (names->symbols) names->geometry = _XkbDupString(names->symbols);
if (names->symbols) names->symbols = _XkbDupString(names->symbols);
XkbInitKeyboardDeviceStruct( dev,names,pSymsIn,pModsIn,bellProc,ctrlProc )    DeviceIntPtr		  dev;    XkbComponentNamesPtr	  names;    KeySymsPtr			  pSymsIn;    CARD8 			  pModsIn[];    void			(*bellProc)();    void			(*ctrlProc)();#endif{XkbFileInfo		finfo;KeySymsRec		tmpSyms,*pSyms;CARD8			tmpMods[XkbMaxLegalKeyCode+1],*pMods;char			name[PATH_MAX],*rules;Bool			ok=False;XPointer		config;XkbComponentNamesRec	cfgNames;XkbRF_VarDefsRec	defs;    if ((dev->key!=NULL)||(dev->kbdfeed!=NULL))	return False;    pSyms= pSymsIn;    pMods= pModsIn;    bzero(&defs,sizeof(XkbRF_VarDefsRec));    bzero(&cfgNames,sizeof(XkbComponentNamesRec));    rules= XkbGetRulesDflts(&defs);    config= XkbDDXPreloadConfig(&rules,&defs,&cfgNames,dev);    /*     * The strings are duplicated because it is not guaranteed that     * they are allocated, or that they are allocated for every server     * 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->geometry = _XkbDupString(names->symbols);    if (defs.model && defs.layout && rules) {	XkbComponentNamesRec	rNames;	bzero(&rNames,sizeof(XkbComponentNamesRec));	if (XkbDDXNamesFromRules(dev,rules,&defs,&rNames)) {	    if (rNames.keymap) {		if (!names->keymap)		    names->keymap = rNames.keymap;		else _XkbFree(rNames.keymap);	    }	    if (rNames.keycodes) {		if (!names->keycodes)		    names->keycodes =  rNames.keycodes;		else		    _XkbFree(rNames.keycodes);	    }	    if (rNames.types) {		if (!names->types)		    names->types = rNames.types;		else  _XkbFree(rNames.types);	    }	    if (rNames.compat) {		if (!names->compat) 		    names->compat =  rNames.compat;		else  _XkbFree(rNames.compat);	    }	    if (rNames.symbols) {		if (!names->symbols)		    names->symbols =  rNames.symbols;		else _XkbFree(rNames.symbols);	    }	    if (rNames.geometry) {		if (!names->geometry)		    names->geometry = rNames.geometry;		else _XkbFree(rNames.geometry);	    }	    XkbSetRulesUsed(&defs);	}    }    if (cfgNames.keymap){	if (names->keymap) _XkbFree(names->keymap);	names->keymap= cfgNames.keymap;    }    if (cfgNames.keycodes){	if (names->keycodes) _XkbFree(names->keycodes);		names->keycodes= cfgNames.keycodes;    }    if (cfgNames.types) {	if (names->types) _XkbFree(names->types);		names->types= cfgNames.types;    }    if (cfgNames.compat) {	if (names->compat) _XkbFree(names->compat);		names->compat= cfgNames.compat;    }    if (cfgNames.symbols){	if (names->symbols) _XkbFree(names->symbols);		names->symbols= cfgNames.symbols;    }    if (cfgNames.geometry) {	if (names->geometry) _XkbFree(names->geometry);	names->geometry= cfgNames.geometry;    }    if (names->keymap) {        XkbComponentNamesRec	tmpNames;	bzero(&tmpNames,sizeof(XkbComponentNamesRec));	tmpNames.keymap = names->keymap;        ok = (Bool) XkbDDXLoadKeymapByNames(dev,&tmpNames,XkmAllIndicesMask,0,					    &finfo,name,PATH_MAX);    }    if (!(ok && (finfo.xkb!=NULL)))        ok = (Bool) XkbDDXLoadKeymapByNames(dev,names,XkmAllIndicesMask,0,					    &finfo,name,PATH_MAX);    if (ok && (finfo.xkb!=NULL)) {	XkbDescPtr	xkb;	int		minKC,maxKC;	xkb= finfo.xkb;	minKC= xkb->min_key_code;	maxKC= xkb->max_key_code;	if (XkbIsLegalKeycode(minKC)&&XkbIsLegalKeycode(maxKC)&&(minKC<=maxKC)&&	    ((minKC!=pSyms->minKeyCode)||(maxKC!=pSyms->maxKeyCode))) {	    if (xkb->map!=NULL) {		KeySym	*inSym,*outSym;		int	width= pSymsIn->mapWidth;		tmpSyms.minKeyCode= minKC;		tmpSyms.maxKeyCode= maxKC;		if (minKC<pSymsIn->minKeyCode)		    minKC= pSymsIn->minKeyCode;		if (maxKC>pSymsIn->maxKeyCode)		    maxKC= pSymsIn->maxKeyCode;		tmpSyms.mapWidth= width;		tmpSyms.map= _XkbTypedCalloc(width*XkbNumKeys(xkb),KeySym);		inSym= &pSymsIn->map[(minKC-pSymsIn->minKeyCode)*width];		outSym= &tmpSyms.map[(minKC-tmpSyms.minKeyCode)*width];		memcpy(outSym,inSym,((maxKC-minKC+1)*width)*sizeof(KeySym));		pSyms= &tmpSyms;	    }	    if ((xkb->map!=NULL)&&(xkb->map->modmap!=NULL)) {		bzero(tmpMods,XkbMaxKeyCount);		memcpy(tmpMods,xkb->map->modmap,maxKC+1);		pMods= tmpMods;	    }	}	_XkbInitFileInfo= &finfo;    }    else {	ErrorF("Couldn't load XKB keymap, falling back to pre-XKB keymap\n");    }    ok= InitKeyboardDeviceStruct((DevicePtr)dev,pSyms,pMods,bellProc,ctrlProc);    if ((config!=NULL)&&(dev && dev->key && dev->key->xkbInfo))	XkbDDXApplyConfig(config,dev->key->xkbInfo);    _XkbInitFileInfo= NULL;    if ((pSyms==&tmpSyms)&&(pSyms->map!=NULL)) {	_XkbFree(pSyms->map);	pSyms->map= NULL;    }    if (names->keymap) _XkbFree(names->keymap);    names->keymap = NULL;    if (names->keycodes) _XkbFree(names->keycodes);    names->keycodes = NULL;    if (names->types) _XkbFree(names->types);    names->types = NULL;    if (names->compat) _XkbFree(names->compat);    names->compat = NULL;    if (names->geometry) _XkbFree(names->geometry);    names->geometry = NULL;    if (names->symbols) _XkbFree(names->symbols);    names->symbols = NULL;    return ok;}