summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-12-10 13:44:17 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2022-12-11 14:35:34 -0800
commit75af06f5f8ffc41fabd100253aad222cb4ab8662 (patch)
treecbb2735d3981ae92b272b761eb966e9c910ecea1
parent265ea3a77418df2744575f1168f89a33f01e72d4 (diff)
Replace uCalloc() and uTypedCalloc() with direct calloc() calls
All these wrappers did was mess with types. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--alias.c2
-rw-r--r--geometry.c14
-rw-r--r--keytypes.c12
-rw-r--r--parseutils.c2
-rw-r--r--symbols.c14
-rw-r--r--utils.c8
-rw-r--r--utils.h4
-rw-r--r--xkbcomp.c6
8 files changed, 25 insertions, 37 deletions
diff --git a/alias.c b/alias.c
index d9e2431..6f39c16 100644
--- a/alias.c
+++ b/alias.c
@@ -103,7 +103,7 @@ HandleAliasDef(KeyAliasDef * def,
return True;
}
}
- info = uTypedCalloc(1, AliasInfo);
+ info = calloc(1, sizeof(AliasInfo));
if (info == NULL)
{
WSGO("Allocation failure in HandleAliasDef\n");
diff --git a/geometry.c b/geometry.c
index 0f375c5..237e730 100644
--- a/geometry.c
+++ b/geometry.c
@@ -884,7 +884,7 @@ NextDfltDoodad(SectionInfo * si, GeometryInfo * info)
{
DoodadInfo *di;
- di = uTypedCalloc(1, DoodadInfo);
+ di = calloc(1, sizeof(DoodadInfo));
if (!di)
return NULL;
if (si)
@@ -907,7 +907,7 @@ NextDoodad(SectionInfo * si, GeometryInfo * info)
{
DoodadInfo *di;
- di = uTypedCalloc(1, DoodadInfo);
+ di = calloc(1, sizeof(DoodadInfo));
if (di)
{
if (si)
@@ -1048,7 +1048,7 @@ AddOverlay(SectionInfo * si, GeometryInfo * info, OverlayInfo * new)
return True;
}
old = new;
- new = uTypedCalloc(1, OverlayInfo);
+ new = calloc(1, sizeof(OverlayInfo));
if (!new)
{
if (warningLevel > 0)
@@ -2404,7 +2404,7 @@ HandleShapeBody(ShapeDef * def, ShapeInfo * si, unsigned merge,
return True;
}
si->nOutlines = def->nOutlines;
- si->outlines = uTypedCalloc(def->nOutlines, XkbOutlineRec);
+ si->outlines = calloc(def->nOutlines, sizeof(XkbOutlineRec));
if (!si->outlines)
{
ERROR("Couldn't allocate outlines for \"%s\"\n",
@@ -2425,7 +2425,7 @@ HandleShapeBody(ShapeDef * def, ShapeInfo * si, unsigned merge,
outline = &si->outlines[nOut++];
outline->num_points = ol->nPoints;
outline->corner_radius = si->dfltCornerRadius;
- outline->points = uTypedCalloc(ol->nPoints, XkbPointRec);
+ outline->points = calloc(ol->nPoints, sizeof(XkbPointRec));
if (!outline->points)
{
ERROR("Can't allocate points for \"%s\"\n",
@@ -2565,7 +2565,7 @@ HandleOverlayDef(OverlayDef * def,
for (OverlayKeyDef *keyDef = def->keys; keyDef;
keyDef = (OverlayKeyDef *) keyDef->common.next)
{
- OverlayKeyInfo *key = uTypedCalloc(1, OverlayKeyInfo);
+ OverlayKeyInfo *key = calloc(1, sizeof(OverlayKeyInfo));
if (!key)
{
if (warningLevel > 0)
@@ -3292,7 +3292,7 @@ FontFromParts(Atom fontTok,
totalSize =
strlen(FONT_TEMPLATE) + strlen(font) + strlen(weight) + strlen(slant);
totalSize += strlen(setWidth) + strlen(variant) + strlen(encoding);
- rtrn = uCalloc(totalSize, 1);
+ rtrn = calloc(totalSize, 1);
if (rtrn)
{
snprintf(rtrn, totalSize, FONT_TEMPLATE, font, weight, slant,
diff --git a/keytypes.c b/keytypes.c
index 79e09fc..a8aaadd 100644
--- a/keytypes.c
+++ b/keytypes.c
@@ -159,8 +159,8 @@ InitKeyTypesInfo(KeyTypesInfo * info, XkbDescPtr xkb, KeyTypesInfo * from)
info->dflt = from->dflt;
if (from->dflt.entries)
{
- info->dflt.entries = uTypedCalloc(from->dflt.szEntries,
- XkbKTMapEntryRec);
+ info->dflt.entries = calloc(from->dflt.szEntries,
+ sizeof(XkbKTMapEntryRec));
if (info->dflt.entries)
{
unsigned sz = from->dflt.nEntries * sizeof(XkbKTMapEntryRec);
@@ -169,7 +169,7 @@ InitKeyTypesInfo(KeyTypesInfo * info, XkbDescPtr xkb, KeyTypesInfo * from)
}
if (from->dflt.lvlNames)
{
- info->dflt.lvlNames = uTypedCalloc(from->dflt.szNames, Atom);
+ info->dflt.lvlNames = calloc(from->dflt.szNames, sizeof(Atom));
if (info->dflt.lvlNames)
{
unsigned sz = from->dflt.szNames * sizeof(Atom);
@@ -512,7 +512,7 @@ NextMapEntry(KeyTypeInfo * type)
{
if (type->entries == NULL)
{
- type->entries = uTypedCalloc(2, XkbKTMapEntryRec);
+ type->entries = calloc(2, sizeof(XkbKTMapEntryRec));
if (type->entries == NULL)
{
ERROR("Couldn't allocate map entries for %s\n", TypeTxt(type));
@@ -1153,7 +1153,7 @@ CopyDefToKeyType(XkbDescPtr xkb, XkbKeyTypePtr type, KeyTypeInfo * def)
type->map = def->entries;
if (def->preserve)
{
- type->preserve = uTypedCalloc(type->map_count, XkbModsRec);
+ type->preserve = calloc(type->map_count, sizeof(XkbModsRec));
if (!type->preserve)
{
WARN("Couldn't allocate preserve array in CopyDefToKeyType\n");
@@ -1177,7 +1177,7 @@ CopyDefToKeyType(XkbDescPtr xkb, XkbKeyTypePtr type, KeyTypeInfo * def)
type->name = (Atom) def->name;
if (def->szNames > 0)
{
- type->level_names = uTypedCalloc(def->numLevels, Atom);
+ type->level_names = calloc(def->numLevels, sizeof(Atom));
/* assert def->szNames<=def->numLevels */
for (int i = 0; i < def->szNames; i++)
diff --git a/parseutils.c b/parseutils.c
index 539aff9..7498b75 100644
--- a/parseutils.c
+++ b/parseutils.c
@@ -435,7 +435,7 @@ CreateKeysymList(char *sym)
{
def->value.list.nSyms = 1;
def->value.list.szSyms = 4;
- def->value.list.syms = uTypedCalloc(4, char *);
+ def->value.list.syms = calloc(4, sizeof(char *));
if (def->value.list.syms != NULL)
{
def->value.list.syms[0] = sym;
diff --git a/symbols.c b/symbols.c
index ba5af49..b026ce7 100644
--- a/symbols.c
+++ b/symbols.c
@@ -166,7 +166,7 @@ CopyKeyInfo(KeyInfo * old, KeyInfo * new, Bool clearOld)
int width = new->numLevels[i];
if (old->syms[i] != NULL)
{
- new->syms[i] = uTypedCalloc(width, KeySym);
+ new->syms[i] = calloc(width, sizeof(KeySym));
if (!new->syms[i])
{
new->syms[i] = NULL;
@@ -178,7 +178,7 @@ CopyKeyInfo(KeyInfo * old, KeyInfo * new, Bool clearOld)
}
if (old->acts[i] != NULL)
{
- new->acts[i] = uTypedCalloc(width, XkbAction);
+ new->acts[i] = calloc(width, sizeof(XkbAction));
if (!new->acts[i])
{
new->acts[i] = NULL;
@@ -242,7 +242,7 @@ InitSymbolsInfo(SymbolsInfo * info, XkbDescPtr xkb)
info->groupInfo = 0;
info->szKeys = SYMBOLS_INIT_SIZE;
info->nKeys = 0;
- info->keys = uTypedCalloc(SYMBOLS_INIT_SIZE, KeyInfo);
+ info->keys = calloc(SYMBOLS_INIT_SIZE, sizeof(KeyInfo));
info->modMap = NULL;
for (int i = 0; i < XkbNumKbdGroups; i++)
info->groupNames[i] = None;
@@ -343,7 +343,7 @@ MergeKeyGroups(SymbolsInfo * info,
}
if (resultSyms == NULL)
{
- resultSyms = uTypedCalloc(resultWidth, KeySym);
+ resultSyms = calloc(resultWidth, sizeof(KeySym));
if (!resultSyms)
{
WSGO("Could not allocate symbols for group merge\n");
@@ -354,7 +354,7 @@ MergeKeyGroups(SymbolsInfo * info,
}
if ((resultActs == NULL) && (into->acts[group] || from->acts[group]))
{
- resultActs = uTypedCalloc(resultWidth, XkbAction);
+ resultActs = calloc(resultWidth, sizeof(XkbAction));
if (!resultActs)
{
WSGO("Could not allocate actions for group merge\n");
@@ -1869,7 +1869,7 @@ PrepareKeyDef(KeyInfo * key)
}
if ((key->actsDefined & 1) && key->acts[0])
{
- key->acts[i] = uTypedCalloc(width, XkbAction);
+ key->acts[i] = calloc(width, sizeof(XkbAction));
if (key->acts[i] == NULL)
continue;
memcpy((void *) key->acts[i], (void *) key->acts[0],
@@ -1878,7 +1878,7 @@ PrepareKeyDef(KeyInfo * key)
}
if ((key->symsDefined & 1) && key->syms[0])
{
- key->syms[i] = uTypedCalloc(width, KeySym);
+ key->syms[i] = calloc(width, sizeof(KeySym));
if (key->syms[i] == NULL)
continue;
memcpy((void *) key->syms[i], (void *) key->syms[0],
diff --git a/utils.c b/utils.c
index 2d605dd..603e8b7 100644
--- a/utils.c
+++ b/utils.c
@@ -34,14 +34,6 @@
/***====================================================================***/
Opaque
-uCalloc(unsigned n, unsigned size)
-{
- return ((Opaque) calloc(n, size));
-}
-
-/***====================================================================***/
-
-Opaque
uRealloc(Opaque old, unsigned newSize)
{
if (old == NULL)
diff --git a/utils.h b/utils.h
index 29e4205..68ec887 100644
--- a/utils.h
+++ b/utils.h
@@ -76,9 +76,6 @@ typedef int Comparison;
/***====================================================================***/
-extern Opaque uCalloc(unsigned /* n */ ,
- unsigned /* size */
- );
extern Opaque uRealloc(Opaque /* old */ ,
unsigned /* newSize */
);
@@ -90,7 +87,6 @@ extern Opaque uRecalloc(Opaque /* old */ ,
extern void uFree(Opaque /* ptr */
);
-#define uTypedCalloc(n,t) ((t *)uCalloc((unsigned)n,(unsigned)sizeof(t)))
#define uTypedRealloc(pO,n,t) ((t *)uRealloc((Opaque)pO,((unsigned)n)*sizeof(t)))
#define uTypedRecalloc(pO,o,n,t) ((t *)uRecalloc((Opaque)pO,((unsigned)o),((unsigned)n),sizeof(t)))
diff --git a/xkbcomp.c b/xkbcomp.c
index b39ac79..0ecccc3 100644
--- a/xkbcomp.c
+++ b/xkbcomp.c
@@ -760,7 +760,7 @@ parseArgs(int argc, char *argv[])
else if ((!outputFile) && (inputFile) && (strcmp(inputFile, "-") == 0))
{
int len = strlen("stdin") + strlen(fileTypeExt[outputFormat]) + 2;
- outputFile = uTypedCalloc(len, char);
+ outputFile = calloc(len, sizeof(char));
if (outputFile == NULL)
{
WSGO("Cannot allocate space for output file name\n");
@@ -786,7 +786,7 @@ parseArgs(int argc, char *argv[])
base = inputMap;
len = strlen(base) + strlen(fileTypeExt[outputFormat]) + 2;
- outputFile = uTypedCalloc(len, char);
+ outputFile = calloc(len, sizeof(char));
if (outputFile == NULL)
{
WSGO("Cannot allocate space for output file name\n");
@@ -812,7 +812,7 @@ parseArgs(int argc, char *argv[])
name = inDpyName;
len = strlen(name) + strlen(fileTypeExt[outputFormat]) + 2;
- outputFile = uTypedCalloc(len, char);
+ outputFile = calloc(len, sizeof(char));
if (outputFile == NULL)
{
WSGO("Cannot allocate space for output file name\n");