aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/xkb/XKBAlloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/xkb/XKBAlloc.c')
-rw-r--r--xorg-server/xkb/XKBAlloc.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/xorg-server/xkb/XKBAlloc.c b/xorg-server/xkb/XKBAlloc.c
index 7265d83f2..6464e9970 100644
--- a/xorg-server/xkb/XKBAlloc.c
+++ b/xorg-server/xkb/XKBAlloc.c
@@ -35,6 +35,8 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "inputstr.h"
#include <xkbsrv.h>
#include "xkbgeom.h"
+#include <os.h>
+#include <string.h>
/***===================================================================***/
@@ -55,24 +57,24 @@ 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;
return BadAlloc;
}
if (compat->num_si!=0) {
- _XkbClearElems(compat->sym_interpret,compat->num_si,
- compat->size_si-1,XkbSymInterpretRec);
+ memset(&compat->sym_interpret[compat->num_si], 0,
+ (compat->size_si - compat->num_si) * sizeof(XkbSymInterpretRec));
}
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 +123,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 +135,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,22 +146,22 @@ 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);
+ memset(&names->key_aliases[names->num_key_aliases], 0,
+ (nTotalAliases - names->num_key_aliases) * sizeof(XkbKeyAliasRec));
} else {
xfree(prev_aliases);
}
@@ -172,16 +174,16 @@ 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);
+ memset(&names->radio_groups[names->num_rg], 0,
+ (nTotalRG - names->num_rg) * sizeof(Atom));
} else {
xfree(prev_radio_groups);
}
@@ -249,7 +251,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 +277,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 +301,7 @@ XkbAllocKeyboard(void)
{
XkbDescRec *xkb;
- xkb = _XkbTypedCalloc(1,XkbDescRec);
+ xkb = xcalloc(1, sizeof(XkbDescRec));
if (xkb)
xkb->device_spec= XkbUseCoreKbd;
return xkb;