[PATCH 01/11] xkb: remove _XkbTyped*alloc

Peter Hutterer peter.hutterer at who-t.net
Thu Jan 14 21:32:09 PST 2010


Please no extension-specific macros for memory allocation.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 include/xkbsrv.h |    4 ---
 xkb/XKBAlloc.c   |   33 +++++++++++++------------
 xkb/XKBGAlloc.c  |    2 +-
 xkb/XKBMAlloc.c  |   71 +++++++++++++++++++++++++++--------------------------
 xkb/XKBMisc.c    |    2 +-
 xkb/ddxList.c    |    2 +-
 xkb/maprules.c   |   16 ++++++------
 xkb/xkb.c        |    7 ++---
 xkb/xkbActions.c |    7 ++---
 xkb/xkbEvents.c  |    2 +-
 xkb/xkbLEDs.c    |   18 +++++++-------
 11 files changed, 80 insertions(+), 84 deletions(-)

diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index ebc7cdb..5d5ea9b 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -299,10 +299,6 @@ extern _X_EXPORT char *	XkbBinDirectory;
 
 extern _X_EXPORT CARD32	xkbDebugFlags;
 
-#define	_XkbTypedAlloc(t)	((t *)xalloc(sizeof(t)))
-#define	_XkbTypedCalloc(n,t)	((t *)Xcalloc((n)*sizeof(t)))
-#define	_XkbTypedRealloc(o,n,t) \
-	((o)?(t *)Xrealloc((o),(n)*sizeof(t)):_XkbTypedCalloc(n,t))
 #define	_XkbClearElems(a,f,l,t)	bzero(&(a)[f],((l)-(f)+1)*sizeof(t))
 
 #define	_XkbLibError(c,l,d) /* Epoch fail */
diff --git a/xkb/XKBAlloc.c b/xkb/XKBAlloc.c
index 7265d83..312f54e 100644
--- a/xkb/XKBAlloc.c
+++ b/xkb/XKBAlloc.c
@@ -35,6 +35,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "inputstr.h"
 #include <xkbsrv.h>
 #include "xkbgeom.h"
+#include <os.h>
 
 /***===================================================================***/
 
@@ -55,8 +56,8 @@ XkbSymInterpretRec *prev_interpret;
 	if (compat->sym_interpret==NULL)
 	    compat->num_si= 0;
 	prev_interpret = compat->sym_interpret;
-	compat->sym_interpret= _XkbTypedRealloc(compat->sym_interpret,
-						     nSI,XkbSymInterpretRec);
+	compat->sym_interpret= xrealloc(compat->sym_interpret,
+					nSI * sizeof(XkbSymInterpretRec));
 	if (compat->sym_interpret==NULL) {
 	    xfree(prev_interpret);
 	    compat->size_si= compat->num_si= 0;
@@ -68,11 +69,11 @@ XkbSymInterpretRec *prev_interpret;
 	}
 	return Success;
     }
-    compat= _XkbTypedCalloc(1,XkbCompatMapRec);
+   compat= xcalloc(1, sizeof(XkbCompatMapRec));
     if (compat==NULL)
 	return BadAlloc;
     if (nSI>0) {
-	compat->sym_interpret= _XkbTypedCalloc(nSI,XkbSymInterpretRec);
+	compat->sym_interpret= xcalloc(nSI, sizeof(XkbSymInterpretRec));
 	if (!compat->sym_interpret) {
 	    xfree(compat);
 	    return BadAlloc;
@@ -121,7 +122,7 @@ XkbNamesPtr	names;
     if (xkb==NULL)
 	return BadMatch;
     if (xkb->names==NULL) {
-	xkb->names = _XkbTypedCalloc(1,XkbNamesRec);
+	xkb->names = xcalloc(1, sizeof(XkbNamesRec));
 	if (xkb->names==NULL)
 	    return BadAlloc;
     }
@@ -133,7 +134,7 @@ XkbNamesPtr	names;
 	type= xkb->map->types;
 	for (i=0;i<xkb->map->num_types;i++,type++) {
 	    if (type->level_names==NULL) {
-		type->level_names= _XkbTypedCalloc(type->num_levels,Atom);
+		type->level_names= xcalloc(type->num_levels, sizeof(Atom));
 		if (type->level_names==NULL)
 		    return BadAlloc;
 	    }
@@ -144,19 +145,19 @@ XkbNamesPtr	names;
 	    (!XkbIsLegalKeycode(xkb->max_key_code))||
 	    (xkb->max_key_code<xkb->min_key_code)) 
 	    return BadValue;
-	names->keys= _XkbTypedCalloc((xkb->max_key_code+1),XkbKeyNameRec);
+	names->keys= xcalloc((xkb->max_key_code+1), sizeof(XkbKeyNameRec));
 	if (names->keys==NULL)
 	    return BadAlloc;
     }
     if ((which&XkbKeyAliasesMask)&&(nTotalAliases>0)) {
 	if (names->key_aliases==NULL) {
-	    names->key_aliases= _XkbTypedCalloc(nTotalAliases,XkbKeyAliasRec);
+	    names->key_aliases= xcalloc(nTotalAliases, sizeof(XkbKeyAliasRec));
 	}
 	else if (nTotalAliases>names->num_key_aliases) {
 	    XkbKeyAliasRec *prev_aliases = names->key_aliases;
 
-	    names->key_aliases= _XkbTypedRealloc(names->key_aliases,
-						nTotalAliases,XkbKeyAliasRec);
+	    names->key_aliases= xrealloc(names->key_aliases,
+					 nTotalAliases * sizeof(XkbKeyAliasRec));
 	    if (names->key_aliases!=NULL) {
 		_XkbClearElems(names->key_aliases,names->num_key_aliases,
 						nTotalAliases-1,XkbKeyAliasRec);
@@ -172,13 +173,13 @@ XkbNamesPtr	names;
     }
     if ((which&XkbRGNamesMask)&&(nTotalRG>0)) {
 	if (names->radio_groups==NULL) {
-	    names->radio_groups= _XkbTypedCalloc(nTotalRG,Atom);
+	    names->radio_groups= xcalloc(nTotalRG, sizeof(Atom));
 	}
 	else if (nTotalRG>names->num_rg) {
 	    Atom *prev_radio_groups = names->radio_groups;
 
-	    names->radio_groups= _XkbTypedRealloc(names->radio_groups,nTotalRG,
-									Atom);
+	    names->radio_groups= xrealloc(names->radio_groups,
+					  nTotalRG * sizeof(Atom));
 	    if (names->radio_groups!=NULL) {
 		_XkbClearElems(names->radio_groups,names->num_rg,nTotalRG-1,
 									Atom);
@@ -249,7 +250,7 @@ XkbAllocControls(XkbDescPtr xkb,unsigned which)
 	return BadMatch;
 
     if (xkb->ctrls==NULL) {
-	xkb->ctrls= _XkbTypedCalloc(1,XkbControlsRec);
+	xkb->ctrls= xcalloc(1, sizeof(XkbControlsRec));
 	if (!xkb->ctrls)
 	    return BadAlloc;
     }
@@ -275,7 +276,7 @@ XkbAllocIndicatorMaps(XkbDescPtr xkb)
     if (xkb==NULL)
 	return BadMatch;
     if (xkb->indicators==NULL) {
-	xkb->indicators= _XkbTypedCalloc(1,XkbIndicatorRec);
+	xkb->indicators= xcalloc(1, sizeof(XkbIndicatorRec));
 	if (!xkb->indicators)
 	    return BadAlloc;
     }
@@ -299,7 +300,7 @@ XkbAllocKeyboard(void)
 {
 XkbDescRec *xkb;
 
-    xkb = _XkbTypedCalloc(1,XkbDescRec);
+    xkb = xcalloc(1, sizeof(XkbDescRec));
     if (xkb)
 	xkb->device_spec= XkbUseCoreKbd;
     return xkb;
diff --git a/xkb/XKBGAlloc.c b/xkb/XKBGAlloc.c
index 752b11a..0bab39a 100644
--- a/xkb/XKBGAlloc.c
+++ b/xkb/XKBGAlloc.c
@@ -615,7 +615,7 @@ XkbGeometryPtr	geom;
 Status		rtrn;
 
     if (xkb->geom==NULL) {
-	xkb->geom= _XkbTypedCalloc(1,XkbGeometryRec);
+	xkb->geom= xcalloc(1, sizeof(XkbGeometryRec));
 	if (!xkb->geom)
 	    return BadAlloc;
     }
diff --git a/xkb/XKBMAlloc.c b/xkb/XKBMAlloc.c
index 728c029..fd12e2b 100644
--- a/xkb/XKBMAlloc.c
+++ b/xkb/XKBMAlloc.c
@@ -59,7 +59,7 @@ XkbClientMapPtr map;
     }
 
     if (xkb->map==NULL) {
-	map= _XkbTypedCalloc(1,XkbClientMapRec);
+	map= xcalloc(1, sizeof(XkbClientMapRec));
 	if (map==NULL)
 	    return BadAlloc;
 	xkb->map= map;
@@ -68,7 +68,7 @@ XkbClientMapPtr map;
 
     if ((which&XkbKeyTypesMask)&&(nTotalTypes>0)) {
 	if (map->types==NULL) {
-	    map->types= _XkbTypedCalloc(nTotalTypes,XkbKeyTypeRec);
+	    map->types= xcalloc(nTotalTypes, sizeof(XkbKeyTypeRec));
 	    if (map->types==NULL)
 		return BadAlloc;
 	    map->num_types= 0;
@@ -77,7 +77,7 @@ XkbClientMapPtr map;
 	else if (map->size_types<nTotalTypes) {
 	    XkbKeyTypeRec *prev_types = map->types;
 
-	    map->types= _XkbTypedRealloc(map->types,nTotalTypes,XkbKeyTypeRec);
+	    map->types= xrealloc(map->types,nTotalTypes * sizeof(XkbKeyTypeRec));
 	    if (map->types==NULL) {
 		xfree(prev_types);
 		map->num_types= map->size_types= 0;
@@ -92,7 +92,7 @@ XkbClientMapPtr map;
 	int nKeys= XkbNumKeys(xkb);
 	if (map->syms==NULL) {
 	    map->size_syms= (nKeys*15)/10;
-	    map->syms= _XkbTypedCalloc(map->size_syms,KeySym);
+	    map->syms= xcalloc(map->size_syms, sizeof(KeySym));
 	    if (!map->syms) {
 		map->size_syms= 0;
 		return BadAlloc;
@@ -102,7 +102,7 @@ XkbClientMapPtr map;
 	}
 	if (map->key_sym_map==NULL) {
 	    i= xkb->max_key_code+1;
-	    map->key_sym_map= _XkbTypedCalloc(i,XkbSymMapRec);
+	    map->key_sym_map= xcalloc(i, sizeof(XkbSymMapRec));
 	    if (map->key_sym_map==NULL)
 		return BadAlloc;
 	}
@@ -114,7 +114,7 @@ XkbClientMapPtr map;
 	    return BadMatch;
 	if (map->modmap==NULL) {
 	    i= xkb->max_key_code+1;
-	    map->modmap= _XkbTypedCalloc(i,unsigned char);
+	    map->modmap= xcalloc(i, sizeof(unsigned char));
 	    if (map->modmap==NULL)
 		return BadAlloc;
 	}
@@ -131,7 +131,7 @@ XkbServerMapPtr map;
     if (xkb==NULL)
 	return BadMatch;
     if (xkb->server==NULL) {
-	map= _XkbTypedCalloc(1,XkbServerMapRec);
+	map= xcalloc(1, sizeof(XkbServerMapRec));
 	if (map==NULL)
 	    return BadAlloc;
 	for (i=0;i<XkbNumVirtualMods;i++) {
@@ -147,7 +147,7 @@ XkbServerMapPtr map;
 	    return BadMatch;
 	if (map->explicit==NULL) {
 	    i= xkb->max_key_code+1;
-	    map->explicit= _XkbTypedCalloc(i,unsigned char);
+	    map->explicit= xcalloc(i, sizeof(unsigned char));
 	    if (map->explicit==NULL)
 		return BadAlloc;
 	}
@@ -160,7 +160,7 @@ XkbServerMapPtr map;
         if (nNewActions<1)
 	    nNewActions= 1;
 	if (map->acts==NULL) {
-	    map->acts= _XkbTypedCalloc((nNewActions+1),XkbAction);
+	    map->acts= xcalloc((nNewActions+1), sizeof(XkbAction));
 	    if (map->acts==NULL)
 		return BadAlloc;
 	    map->num_acts= 1;
@@ -170,7 +170,7 @@ XkbServerMapPtr map;
 	    unsigned need;
 	    XkbAction *prev_acts = map->acts;
 	    need= map->num_acts+nNewActions;
-	    map->acts= _XkbTypedRealloc(map->acts,need,XkbAction);
+	    map->acts= xrealloc(map->acts,need * sizeof(XkbAction));
 	    if (map->acts==NULL) {
 		xfree(prev_acts);
 	        map->num_acts= map->size_acts= 0;
@@ -182,7 +182,7 @@ XkbServerMapPtr map;
 	}
 	if (map->key_acts==NULL) {
 	    i= xkb->max_key_code+1;
-	    map->key_acts= _XkbTypedCalloc(i,unsigned short);
+	    map->key_acts= xcalloc(i, sizeof(unsigned short));
 	    if (map->key_acts==NULL)
 		return BadAlloc;
 	}
@@ -194,7 +194,7 @@ XkbServerMapPtr map;
 	    return BadMatch;
 	if (map->behaviors==NULL) {
 	    i= xkb->max_key_code+1;
-	    map->behaviors= _XkbTypedCalloc(i,XkbBehavior);
+	    map->behaviors= xcalloc(i, sizeof(XkbBehavior));
 	    if (map->behaviors==NULL)
 		return BadAlloc;
 	}
@@ -206,7 +206,7 @@ XkbServerMapPtr map;
 	    return BadMatch;
 	if (map->vmodmap==NULL) {
 	    i= xkb->max_key_code+1;
-	    map->vmodmap= _XkbTypedCalloc(i,unsigned short);
+	    map->vmodmap= xcalloc(i, sizeof(unsigned short));
 	    if (map->vmodmap==NULL)
 		return BadAlloc;
 	}
@@ -235,20 +235,20 @@ XkbCopyKeyType(XkbKeyTypePtr from,XkbKeyTypePtr into)
     }
     *into= *from;
     if ((from->map)&&(into->map_count>0)) {
-	into->map= _XkbTypedCalloc(into->map_count,XkbKTMapEntryRec);
+	into->map= xcalloc(into->map_count, sizeof(XkbKTMapEntryRec));
 	if (!into->map)
 	    return BadAlloc;
 	memcpy(into->map,from->map,into->map_count*sizeof(XkbKTMapEntryRec));
     }
     if ((from->preserve)&&(into->map_count>0)) {
-	into->preserve= _XkbTypedCalloc(into->map_count,XkbModsRec);
+	into->preserve= xcalloc(into->map_count, sizeof(XkbModsRec));
 	if (!into->preserve)
 	    return BadAlloc;
 	memcpy(into->preserve,from->preserve,
 				into->map_count*sizeof(XkbModsRec));
     }
     if ((from->level_names)&&(into->num_levels>0)) {
-	into->level_names= _XkbTypedCalloc(into->num_levels,Atom);
+	into->level_names= xcalloc(into->num_levels, sizeof(Atom));
 	if (!into->level_names)
 	    return BadAlloc;
 	memcpy(into->level_names,from->level_names,
@@ -310,7 +310,7 @@ KeyCode		matchingKeys[XkbMaxKeyCount],nMatchingKeys;
 	XkbKTMapEntryRec *prev_map = type->map;
 
 	if ((map_count>type->map_count)||(type->map==NULL))
-	    type->map=_XkbTypedRealloc(type->map,map_count,XkbKTMapEntryRec);
+	    type->map = xrealloc(type->map,map_count * sizeof(XkbKTMapEntryRec));
 	if (!type->map) {
 	    if (prev_map) 
 		xfree(prev_map);
@@ -320,8 +320,8 @@ KeyCode		matchingKeys[XkbMaxKeyCount],nMatchingKeys;
 	    XkbModsRec *prev_preserve = type->preserve;
 
 	    if ((map_count>type->map_count)||(type->preserve==NULL)) {
-		type->preserve= _XkbTypedRealloc(type->preserve,map_count,
-	     						    XkbModsRec);
+		type->preserve = xrealloc(type->preserve,
+					  map_count * sizeof(XkbModsRec));
 	    }
 	    if (!type->preserve) {
 		if (prev_preserve) 
@@ -339,7 +339,8 @@ KeyCode		matchingKeys[XkbMaxKeyCount],nMatchingKeys;
     if ((new_num_lvls>type->num_levels)||(type->level_names==NULL)) {
 	Atom * prev_level_names = type->level_names;
 
-	type->level_names=_XkbTypedRealloc(type->level_names,new_num_lvls,Atom);
+	type->level_names = xrealloc(type->level_names,
+				     new_num_lvls * sizeof(Atom));
 	if (!type->level_names) {
 	    if (prev_level_names) 
 		xfree(prev_level_names);
@@ -396,7 +397,7 @@ KeyCode		matchingKeys[XkbMaxKeyCount],nMatchingKeys;
 	if (nResize>0) {
 	    int nextMatch;
 	    xkb->map->size_syms= (nTotal*15)/10;
-	    newSyms = _XkbTypedCalloc(xkb->map->size_syms,KeySym);
+	    newSyms = xcalloc(xkb->map->size_syms, sizeof(KeySym));
 	    if (newSyms==NULL)
 		return BadAlloc;
 	    nextMatch= 0;
@@ -498,7 +499,7 @@ KeySym	*newSyms;
 	return &xkb->map->syms[xkb->map->key_sym_map[key].offset];
     }
     xkb->map->size_syms+= (needed>32?needed:32);
-    newSyms = _XkbTypedCalloc(xkb->map->size_syms,KeySym);
+    newSyms = xcalloc(xkb->map->size_syms, sizeof(KeySym));
     if (newSyms==NULL)
 	return NULL;
     newSyms[0]= NoSymbol;
@@ -637,8 +638,8 @@ int	tmp;
 	    if (xkb->map->key_sym_map) {
 		XkbSymMapRec *prev_key_sym_map = xkb->map->key_sym_map;
 
-		xkb->map->key_sym_map= _XkbTypedRealloc(xkb->map->key_sym_map,
-						(maxKC+1),XkbSymMapRec);
+		xkb->map->key_sym_map = xrealloc(xkb->map->key_sym_map,
+						(maxKC+1) * sizeof(XkbSymMapRec));
 		if (!xkb->map->key_sym_map) {
 		    xfree(prev_key_sym_map);
 		    return BadAlloc;
@@ -655,8 +656,8 @@ int	tmp;
 	    if (xkb->map->modmap) {
 		unsigned char *prev_modmap = xkb->map->modmap;
 
-		xkb->map->modmap= _XkbTypedRealloc(xkb->map->modmap,
-						(maxKC+1),unsigned char);
+		xkb->map->modmap = xrealloc(xkb->map->modmap,
+					    (maxKC+1) * sizeof(unsigned char));
 		if (!xkb->map->modmap) {
 		    xfree(prev_modmap);
 		    return BadAlloc;
@@ -674,8 +675,8 @@ int	tmp;
 	    if (xkb->server->behaviors) {
 		XkbBehavior *prev_behaviors = xkb->server->behaviors;
 
-		xkb->server->behaviors=_XkbTypedRealloc(xkb->server->behaviors,
-						(maxKC+1),XkbBehavior);
+		xkb->server->behaviors = xrealloc(xkb->server->behaviors,
+						(maxKC+1) * sizeof(XkbBehavior));
 		if (!xkb->server->behaviors) {
 		    xfree(prev_behaviors);
 		    return BadAlloc;
@@ -692,8 +693,8 @@ int	tmp;
 	    if (xkb->server->key_acts) {
 		unsigned short *prev_key_acts = xkb->server->key_acts;
 
-		xkb->server->key_acts= _XkbTypedRealloc(xkb->server->key_acts,
-						(maxKC+1),unsigned short);
+		xkb->server->key_acts= xrealloc(xkb->server->key_acts,
+						(maxKC+1) * sizeof(unsigned short));
 		if (!xkb->server->key_acts) {
 		    xfree(prev_key_acts);
 		    return BadAlloc;
@@ -710,8 +711,8 @@ int	tmp;
 	    if (xkb->server->vmodmap) {
 		unsigned short *prev_vmodmap = xkb->server->vmodmap;
 
-		xkb->server->vmodmap= _XkbTypedRealloc(xkb->server->vmodmap,
-						(maxKC+1),unsigned short);
+		xkb->server->vmodmap= xrealloc(xkb->server->vmodmap,
+						(maxKC+1) * sizeof(unsigned short));
 		if (!xkb->server->vmodmap) {
 		    xfree(prev_vmodmap);
 		    return BadAlloc;
@@ -729,8 +730,8 @@ int	tmp;
 	if ((xkb->names)&&(xkb->names->keys)) {
 	    XkbKeyNameRec *prev_keys = xkb->names->keys;
 
-	    xkb->names->keys= _XkbTypedRealloc(xkb->names->keys,
-	    					(maxKC+1),XkbKeyNameRec);
+	    xkb->names->keys = xrealloc(xkb->names->keys,
+					(maxKC+1) * sizeof(XkbKeyNameRec));
 	    if (!xkb->names->keys) {
 		xfree(prev_keys);
 		return BadAlloc;
@@ -767,7 +768,7 @@ XkbAction *newActs;
 	return &xkb->server->acts[xkb->server->key_acts[key]];
     }
     xkb->server->size_acts= xkb->server->num_acts+needed+8;
-    newActs = _XkbTypedCalloc(xkb->server->size_acts,XkbAction);
+    newActs = xcalloc(xkb->server->size_acts, sizeof(XkbAction));
     if (newActs==NULL)
 	return NULL;
     newActs[0].type = XkbSA_NoAction;
diff --git a/xkb/XKBMisc.c b/xkb/XKBMisc.c
index 8679060..71fa044 100644
--- a/xkb/XKBMisc.c
+++ b/xkb/XKBMisc.c
@@ -388,7 +388,7 @@ unsigned		changed,tmp;
     nSyms= XkbKeyNumSyms(xkb,key);
     syms= XkbKeySymsPtr(xkb,key);
     if (nSyms>IBUF_SIZE) {
-	interps= _XkbTypedCalloc(nSyms,XkbSymInterpretPtr);
+	interps= xcalloc(nSyms, sizeof(XkbSymInterpretPtr));
 	if (interps==NULL) {
 	    interps= ibuf;
 	    nSyms= IBUF_SIZE;
diff --git a/xkb/ddxList.c b/xkb/ddxList.c
index 3ff3d81..bf49311 100644
--- a/xkb/ddxList.c
+++ b/xkb/ddxList.c
@@ -97,7 +97,7 @@ char *		tmp;
     if ((list->szPool-list->nPool)<wlen) {
 	if (wlen>1024)	list->szPool+= XkbPaddedSize(wlen*2);
 	else		list->szPool+= 1024;
-	list->pool= _XkbTypedRealloc(list->pool,list->szPool,char);
+	list->pool= xrealloc(list->pool, list->szPool * sizeof(char));
 	if (!list->pool)
 	    return BadAlloc;
     }
diff --git a/xkb/maprules.c b/xkb/maprules.c
index 168c527..ec6fe3f 100644
--- a/xkb/maprules.c
+++ b/xkb/maprules.c
@@ -474,7 +474,7 @@ int len;
     if ((!str1)||(!str2))
 	return str1;
     len= strlen(str1)+strlen(str2)+1;
-    str1= _XkbTypedRealloc(str1,len,char);
+    str1= xrealloc(str1,len * sizeof(char));
     if (str1)
 	strcat(str1,str2);
     return str1;
@@ -864,12 +864,12 @@ XkbRF_AddRule(XkbRF_RulesPtr	rules)
     if (rules->sz_rules<1) {
 	rules->sz_rules= 16;
 	rules->num_rules= 0;
-	rules->rules= _XkbTypedCalloc(rules->sz_rules,XkbRF_RuleRec);
+	rules->rules= xcalloc(rules->sz_rules, sizeof(XkbRF_RuleRec));
     }
     else if (rules->num_rules>=rules->sz_rules) {
 	rules->sz_rules*= 2;
-	rules->rules= _XkbTypedRealloc(rules->rules,rules->sz_rules,
-							XkbRF_RuleRec);
+	rules->rules= xrealloc(rules->rules,
+				rules->sz_rules * sizeof(XkbRF_RuleRec));
     }
     if (!rules->rules) {
 	rules->sz_rules= rules->num_rules= 0;
@@ -886,12 +886,12 @@ XkbRF_AddGroup(XkbRF_RulesPtr	rules)
     if (rules->sz_groups<1) {
 	rules->sz_groups= 16;
 	rules->num_groups= 0;
-	rules->groups= _XkbTypedCalloc(rules->sz_groups,XkbRF_GroupRec);
+	rules->groups= xcalloc(rules->sz_groups, sizeof(XkbRF_GroupRec));
     }
     else if (rules->num_groups >= rules->sz_groups) {
 	rules->sz_groups *= 2;
-	rules->groups= _XkbTypedRealloc(rules->groups,rules->sz_groups,
-							XkbRF_GroupRec);
+	rules->groups= xrealloc(rules->groups,
+				rules->sz_groups * sizeof(XkbRF_GroupRec));
     }
     if (!rules->groups) {
 	rules->sz_groups= rules->num_groups= 0;
@@ -972,7 +972,7 @@ Bool		ok;
 XkbRF_RulesPtr
 XkbRF_Create(void)
 {
-    return _XkbTypedCalloc(1, XkbRF_RulesRec);
+    return xcalloc(1, sizeof( XkbRF_RulesRec));
 }
 
 /***====================================================================***/
diff --git a/xkb/xkb.c b/xkb/xkb.c
index 2b69fce..a0e7d5f 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -2780,9 +2780,8 @@ _XkbSetCompatMap(ClientPtr client, DeviceIntPtr dev,
 	XkbSymInterpretPtr	sym;
 	if ((unsigned)(req->firstSI+req->nSI)>compat->num_si) {
 	    compat->num_si= req->firstSI+req->nSI;
-	    compat->sym_interpret= _XkbTypedRealloc(compat->sym_interpret,
-						   compat->num_si,
-						   XkbSymInterpretRec);
+	    compat->sym_interpret= xrealloc(compat->sym_interpret,
+					    compat->num_si * sizeof(XkbSymInterpretRec));
 	    if (!compat->sym_interpret) {
 		compat->num_si= 0;
 		return BadAlloc;
@@ -6463,7 +6462,7 @@ _XkbSetDeviceInfoCheck(ClientPtr client, DeviceIntPtr dev,
 	nBtns= dev->button->numButtons;
 	acts= dev->button->xkb_acts;
 	if (acts==NULL) {
-	    acts= _XkbTypedCalloc(nBtns,XkbAction);
+	    acts= xcalloc(nBtns, sizeof(XkbAction));
 	    if (!acts)
 		return BadAlloc;
 	    dev->button->xkb_acts= acts;
diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index b0ab427..75f3c72 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -1016,7 +1016,7 @@ register int	i;
 
     if (xkbi->szFilters==0) {
 	xkbi->szFilters = 4;
-	xkbi->filters = _XkbTypedCalloc(xkbi->szFilters,XkbFilterRec);
+	xkbi->filters = xcalloc(xkbi->szFilters, sizeof(XkbFilterRec));
 	/* 6/21/93 (ef) -- XXX! deal with allocation failure */
     }
     for (i=0;i<xkbi->szFilters;i++) {
@@ -1026,9 +1026,8 @@ register int	i;
 	}
     }
     xkbi->szFilters*=2;
-    xkbi->filters= _XkbTypedRealloc(xkbi->filters,
-                                    xkbi->szFilters,
-                                    XkbFilterRec);
+    xkbi->filters= xrealloc(xkbi->filters,
+                            xkbi->szFilters * sizeof(XkbFilterRec));
     /* 6/21/93 (ef) -- XXX! deal with allocation failure */
     bzero(&xkbi->filters[xkbi->szFilters/2],
             (xkbi->szFilters/2)*sizeof(XkbFilterRec));
diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c
index 8fb49c1..58f75b3 100644
--- a/xkb/xkbEvents.c
+++ b/xkb/xkbEvents.c
@@ -1041,7 +1041,7 @@ XkbInterestPtr	interest;
 	    return ((interest->resource==id)?interest:NULL);
 	interest = interest->next;
     }
-    interest = _XkbTypedAlloc(XkbInterestRec);
+    interest = xalloc(sizeof(XkbInterestRec));
     bzero(interest,sizeof(XkbInterestRec));
     if (interest) {
 	interest->dev = dev;
diff --git a/xkb/xkbLEDs.c b/xkb/xkbLEDs.c
index 6ca80d7..3cf24e3 100644
--- a/xkb/xkbLEDs.c
+++ b/xkb/xkbLEDs.c
@@ -524,7 +524,7 @@ Bool			checkNames;
     sli= NULL;
     checkAccel= checkNames= False;
     if ((kf!=NULL)&&(kf->xkb_sli==NULL)) {
-	kf->xkb_sli= sli= _XkbTypedCalloc(1,XkbSrvLedInfoRec);
+	kf->xkb_sli= sli= xcalloc(1, sizeof(XkbSrvLedInfoRec));
 	if (sli==NULL)
 	    return NULL; /* ALLOCATION ERROR */
 	if (dev->key && dev->key->xkbInfo)
@@ -567,7 +567,7 @@ Bool			checkNames;
 	}
     }
     else if ((lf!=NULL)&&(lf->xkb_sli==NULL)) {
-	lf->xkb_sli= sli= _XkbTypedCalloc(1,XkbSrvLedInfoRec);
+	lf->xkb_sli= sli= xcalloc(1, sizeof(XkbSrvLedInfoRec));
 	if (sli==NULL)
 	    return NULL; /* ALLOCATION ERROR */
 	if (dev->key && dev->key->xkbInfo)
@@ -585,9 +585,9 @@ Bool			checkNames;
 	sli->names=		NULL;
     }
     if ((sli->names==NULL)&&(needed_parts&XkbXI_IndicatorNamesMask))
-	sli->names= _XkbTypedCalloc(XkbNumIndicators,Atom);
+	sli->names= xcalloc(XkbNumIndicators, sizeof(Atom));
     if ((sli->maps==NULL)&&(needed_parts&XkbXI_IndicatorMapsMask))
-	sli->maps= _XkbTypedCalloc(XkbNumIndicators,XkbIndicatorMapRec);
+	sli->maps= xcalloc(XkbNumIndicators, sizeof(XkbIndicatorMapRec));
     if (checkNames) {
 	register unsigned i,bit;
 	sli->namesPresent=	0;
@@ -633,7 +633,7 @@ XkbCopySrvLedInfo(	DeviceIntPtr		from,
     if (!src)
 	goto finish;
 
-    sli_new = _XkbTypedCalloc(1, XkbSrvLedInfoRec);
+    sli_new = xcalloc(1, sizeof( XkbSrvLedInfoRec));
     if (!sli_new)
 	goto finish;
 
@@ -644,8 +644,8 @@ XkbCopySrvLedInfo(	DeviceIntPtr		from,
 	sli_new->fb.lf = lf;
 
     if (!(sli_new->flags & XkbSLI_IsDefault)) {
-	sli_new->names= _XkbTypedCalloc(XkbNumIndicators,Atom);
-	sli_new->maps= _XkbTypedCalloc(XkbNumIndicators,XkbIndicatorMapRec);
+	sli_new->names= xcalloc(XkbNumIndicators, sizeof(Atom));
+	sli_new->maps= xcalloc(XkbNumIndicators, sizeof(XkbIndicatorMapRec));
     } /* else sli_new->names/maps is pointing to
 	dev->key->xkbInfo->desc->names->indicators;
 	dev->key->xkbInfo->desc->names->indicators; */
@@ -715,9 +715,9 @@ XkbSrvLedInfoPtr	sli;
 	}
     }
     if ((sli->names==NULL)&&(needed_parts&XkbXI_IndicatorNamesMask))
-	sli->names= _XkbTypedCalloc(XkbNumIndicators,Atom);
+	sli->names= xcalloc(XkbNumIndicators, sizeof(Atom));
     if ((sli->maps==NULL)&&(needed_parts&XkbXI_IndicatorMapsMask))
-	sli->maps= _XkbTypedCalloc(XkbNumIndicators,XkbIndicatorMapRec);
+	sli->maps= xcalloc(XkbNumIndicators, sizeof(XkbIndicatorMapRec));
     return sli;
 }
 
-- 
1.6.6



More information about the xorg-devel mailing list