diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-12-10 13:39:10 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-12-11 14:35:34 -0800 |
commit | 265ea3a77418df2744575f1168f89a33f01e72d4 (patch) | |
tree | 7b67b74b0a3b3e519f80b78e56be491acd748653 | |
parent | 81e51cf1ff494131827df487a0f538c3b07e0407 (diff) |
Replace uAlloc() and uTypedAlloc() with direct malloc() calls
All these wrappers did was mess with types.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | action.c | 2 | ||||
-rw-r--r-- | compat.c | 2 | ||||
-rw-r--r-- | expr.c | 2 | ||||
-rw-r--r-- | geometry.c | 10 | ||||
-rw-r--r-- | indicators.c | 2 | ||||
-rw-r--r-- | keycodes.c | 2 | ||||
-rw-r--r-- | keytypes.c | 6 | ||||
-rw-r--r-- | listing.c | 2 | ||||
-rw-r--r-- | parseutils.c | 52 | ||||
-rw-r--r-- | symbols.c | 2 | ||||
-rw-r--r-- | utils.c | 9 | ||||
-rw-r--r-- | utils.h | 11 | ||||
-rw-r--r-- | xkbpath.c | 2 |
13 files changed, 48 insertions, 56 deletions
@@ -1449,7 +1449,7 @@ SetActionField(XkbDescPtr xkb, if (!actionsInitialized) ActionsInit(); - new = uTypedAlloc(ActionInfo); + new = malloc(sizeof(ActionInfo)); if (new == NULL) { WSGO("Couldn't allocate space for action default\n"); @@ -161,7 +161,7 @@ NextInterp(CompatInfo * info) { SymInterpInfo *si; - si = uTypedAlloc(SymInterpInfo); + si = malloc(sizeof(SymInterpInfo)); if (si) { bzero((char *) si, sizeof(SymInterpInfo)); @@ -765,7 +765,7 @@ ExprResolveString(ExprDef * expr, int len; char *new; len = strlen(leftRtrn.str) + strlen(rightRtrn.str) + 1; - new = (char *) uAlloc(len); + new = malloc(len); if (new) { snprintf(new, len, "%s%s", leftRtrn.str, rightRtrn.str); @@ -702,7 +702,7 @@ NextProperty(GeometryInfo * info) { PropertyInfo *pi; - pi = uTypedAlloc(PropertyInfo); + pi = malloc(sizeof(PropertyInfo)); if (pi) { bzero((char *) pi, sizeof(PropertyInfo)); @@ -780,7 +780,7 @@ NextShape(GeometryInfo * info) { ShapeInfo *si; - si = uTypedAlloc(ShapeInfo); + si = malloc(sizeof(ShapeInfo)); if (si) { bzero((char *) si, sizeof(ShapeInfo)); @@ -1077,7 +1077,7 @@ NextSection(GeometryInfo * info) { SectionInfo *si; - si = uTypedAlloc(SectionInfo); + si = malloc(sizeof(SectionInfo)); if (si) { *si = info->dfltSection; @@ -1167,7 +1167,7 @@ NextRow(SectionInfo * si) { RowInfo *row; - row = uTypedAlloc(RowInfo); + row = malloc(sizeof(RowInfo)); if (row) { *row = si->dfltRow; @@ -1204,7 +1204,7 @@ NextKey(RowInfo * row) { KeyInfo *key; - key = uTypedAlloc(KeyInfo); + key = malloc(sizeof(KeyInfo)); if (key) { *key = row->dfltKey; diff --git a/indicators.c b/indicators.c index 4eaa6ae..0e82d4a 100644 --- a/indicators.c +++ b/indicators.c @@ -147,7 +147,7 @@ AddIndicatorMap(LEDInfo * oldLEDs, LEDInfo * new) last = old; } /* new definition */ - old = uTypedAlloc(LEDInfo); + old = malloc(sizeof(LEDInfo)); if (!old) { WSGO("Couldn't allocate indicator map\n"); @@ -117,7 +117,7 @@ NextIndicatorName(KeyNamesInfo * info) { IndicatorNameInfo *ii; - ii = uTypedAlloc(IndicatorNameInfo); + ii = malloc(sizeof(IndicatorNameInfo)); if (ii) { InitIndicatorNameInfo(ii, info); @@ -183,7 +183,7 @@ InitKeyTypesInfo(KeyTypesInfo * info, XkbDescPtr xkb, KeyTypesInfo * from) for (PreserveInfo *old = from->dflt.preserve; old; old = (PreserveInfo *) old->defs.next) { - PreserveInfo *new = uTypedAlloc(PreserveInfo); + PreserveInfo *new = malloc(sizeof(PreserveInfo)); if (!new) return; *new = *old; @@ -245,7 +245,7 @@ NextKeyType(KeyTypesInfo * info) { KeyTypeInfo *type; - type = uTypedAlloc(KeyTypeInfo); + type = malloc(sizeof(KeyTypeInfo)); if (type != NULL) { bzero(type, sizeof(KeyTypeInfo)); @@ -588,7 +588,7 @@ AddPreserve(XkbDescPtr xkb, } return True; } - old = uTypedAlloc(PreserveInfo); + old = malloc(sizeof(PreserveInfo)); if (!old) { WSGO("Couldn't allocate preserve in %s\n", TypeTxt(type)); @@ -311,7 +311,7 @@ AddDirectory(char *head, char *ptrn, char *rest, char *map) if (ptrn && (!XkbNameMatchesPattern(filename, ptrn))) continue; tmpsize = (head ? strlen(head) : 0) + strlen(filename) + 2; - tmp = uAlloc(tmpsize); + tmp = malloc(tmpsize); if (!tmp) continue; snprintf(tmp, tmpsize, "%s%s%s", diff --git a/parseutils.c b/parseutils.c index dac463a..539aff9 100644 --- a/parseutils.c +++ b/parseutils.c @@ -57,7 +57,7 @@ ExprDef * ExprCreate(unsigned op, unsigned type) { ExprDef *expr; - expr = uTypedAlloc(ExprDef); + expr = malloc(sizeof(ExprDef)); if (expr) { *expr = (ExprDef) { @@ -79,7 +79,7 @@ ExprDef * ExprCreateUnary(unsigned op, unsigned type, ExprDef * child) { ExprDef *expr; - expr = uTypedAlloc(ExprDef); + expr = malloc(sizeof(ExprDef)); if (expr) { *expr = (ExprDef) { @@ -102,7 +102,7 @@ ExprDef * ExprCreateBinary(unsigned op, ExprDef * left, ExprDef * right) { ExprDef *expr; - expr = uTypedAlloc(ExprDef); + expr = malloc(sizeof(ExprDef)); if (expr) { *expr = (ExprDef) { @@ -132,7 +132,7 @@ KeycodeCreate(char *name, ExprDef * value) { KeycodeDef *def; - def = uTypedAlloc(KeycodeDef); + def = malloc(sizeof(KeycodeDef)); if (def) { *def = (KeycodeDef) { @@ -156,7 +156,7 @@ KeyAliasCreate(char *alias, char *real) { KeyAliasDef *def; - def = uTypedAlloc(KeyAliasDef); + def = malloc(sizeof(KeyAliasDef)); if (def) { *def = (KeyAliasDef) { @@ -180,7 +180,7 @@ VModDef * VModCreate(Atom name, ExprDef * value) { VModDef *def; - def = uTypedAlloc(VModDef); + def = malloc(sizeof(VModDef)); if (def) { *def = (VModDef) { @@ -202,7 +202,7 @@ VarDef * VarCreate(ExprDef * name, ExprDef * value) { VarDef *def; - def = uTypedAlloc(VarDef); + def = malloc(sizeof(VarDef)); if (def) { *def = (VarDef) { @@ -237,7 +237,7 @@ InterpCreate(const char *sym_str, ExprDef * match) { InterpDef *def; - def = uTypedAlloc(InterpDef); + def = malloc(sizeof(InterpDef)); if (def) { *def = (InterpDef) { @@ -263,7 +263,7 @@ KeyTypeCreate(Atom name, VarDef * body) { KeyTypeDef *def; - def = uTypedAlloc(KeyTypeDef); + def = malloc(sizeof(KeyTypeDef)); if (def) { *def = (KeyTypeDef) { @@ -287,7 +287,7 @@ SymbolsCreate(char *keyName, ExprDef * symbols) { SymbolsDef *def; - def = uTypedAlloc(SymbolsDef); + def = malloc(sizeof(SymbolsDef)); if (def) { *def = (SymbolsDef) { @@ -312,7 +312,7 @@ GroupCompatCreate(int group, ExprDef * val) { GroupCompatDef *def; - def = uTypedAlloc(GroupCompatDef); + def = malloc(sizeof(GroupCompatDef)); if (def) { *def = (GroupCompatDef) { @@ -336,7 +336,7 @@ ModMapCreate(Atom modifier, ExprDef * keys) { ModMapDef *def; - def = uTypedAlloc(ModMapDef); + def = malloc(sizeof(ModMapDef)); if (def) { *def = (ModMapDef) { @@ -360,7 +360,7 @@ IndicatorMapCreate(Atom name, VarDef * body) { IndicatorMapDef *def; - def = uTypedAlloc(IndicatorMapDef); + def = malloc(sizeof(IndicatorMapDef)); if (def) { *def = (IndicatorMapDef) { @@ -384,7 +384,7 @@ IndicatorNameCreate(int ndx, ExprDef * name, Bool virtual) { IndicatorNameDef *def; - def = uTypedAlloc(IndicatorNameDef); + def = malloc(sizeof(IndicatorNameDef)); if (def) { *def = (IndicatorNameDef) { @@ -409,7 +409,7 @@ ActionCreate(Atom name, ExprDef * args) { ExprDef *act; - act = uTypedAlloc(ExprDef); + act = malloc(sizeof(ExprDef)); if (act) { *act = (ExprDef) { @@ -451,7 +451,7 @@ ShapeDeclCreate(Atom name, OutlineDef * outlines) { ShapeDef *shape; - shape = uTypedAlloc(ShapeDef); + shape = malloc(sizeof(ShapeDef)); if (shape != NULL) { bzero(shape, sizeof(ShapeDef)); @@ -478,7 +478,7 @@ OutlineCreate(Atom field, ExprDef * points) { OutlineDef *outline; - outline = uTypedAlloc(OutlineDef); + outline = malloc(sizeof(OutlineDef)); if (outline != NULL) { bzero(outline, sizeof(OutlineDef)); @@ -506,7 +506,7 @@ KeyDeclCreate(char *name, ExprDef * expr) { KeyDef *key; - key = uTypedAlloc(KeyDef); + key = malloc(sizeof(KeyDef)); if (key != NULL) { bzero(key, sizeof(KeyDef)); @@ -537,7 +537,7 @@ RowDeclCreate(KeyDef * keys) { RowDef *row; - row = uTypedAlloc(RowDef); + row = malloc(sizeof(RowDef)); if (row != NULL) { bzero(row, sizeof(RowDef)); @@ -561,7 +561,7 @@ SectionDeclCreate(Atom name, RowDef * rows) { SectionDef *section; - section = uTypedAlloc(SectionDef); + section = malloc(sizeof(SectionDef)); if (section != NULL) { bzero(section, sizeof(SectionDef)); @@ -586,7 +586,7 @@ OverlayKeyCreate(char *under, char *over) { OverlayKeyDef *key; - key = uTypedAlloc(OverlayKeyDef); + key = malloc(sizeof(OverlayKeyDef)); if (key != NULL) { bzero(key, sizeof(OverlayKeyDef)); @@ -606,7 +606,7 @@ OverlayDeclCreate(Atom name, OverlayKeyDef * keys) { OverlayDef *ol; - ol = uTypedAlloc(OverlayDef); + ol = malloc(sizeof(OverlayDef)); if (ol != NULL) { bzero(ol, sizeof(OverlayDef)); @@ -629,7 +629,7 @@ DoodadCreate(unsigned type, Atom name, VarDef * body) { DoodadDef *doodad; - doodad = uTypedAlloc(DoodadDef); + doodad = malloc(sizeof(DoodadDef)); if (doodad != NULL) { bzero(doodad, sizeof(DoodadDef)); @@ -723,10 +723,10 @@ IncludeCreate(char *str, unsigned merge) haveSelf = True; } if (first == NULL) - first = incl = uTypedAlloc(IncludeStmt); + first = incl = malloc(sizeof(IncludeStmt)); else { - incl->next = uTypedAlloc(IncludeStmt); + incl->next = malloc(sizeof(IncludeStmt)); incl = incl->next; } if (incl) @@ -861,7 +861,7 @@ CreateXKBFile(int type, char *name, ParseCommon * defs, unsigned flags) XkbFile *file; static int fileID; - file = uTypedAlloc(XkbFile); + file = malloc(sizeof(XkbFile)); if (file) { XkbEnsureSafeMapName(name); @@ -682,7 +682,7 @@ AddModMapEntry(SymbolsInfo * info, ModMapEntry * new) return True; } } - mm = uTypedAlloc(ModMapEntry); + mm = malloc(sizeof(ModMapEntry)); if (mm == NULL) { WSGO("Could not allocate modifier map entry\n"); @@ -30,13 +30,6 @@ #include <stdlib.h> #include <stdarg.h> -/***====================================================================***/ - -Opaque -uAlloc(unsigned size) -{ - return ((Opaque) malloc(size)); -} /***====================================================================***/ @@ -315,7 +308,7 @@ uStringDup(const char *str) if (str == NULL) return NULL; - rtrn = (char *) uAlloc(strlen(str) + 1); + rtrn = malloc(strlen(str) + 1); strcpy(rtrn, str); return rtrn; } @@ -29,15 +29,17 @@ /***====================================================================***/ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdio.h> +#include <stdlib.h> #include <X11/Xos.h> #include <X11/Xfuncproto.h> #include <X11/Xfuncs.h> #include <stddef.h> -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif #ifndef NUL #define NUL '\0' @@ -74,8 +76,6 @@ typedef int Comparison; /***====================================================================***/ -extern Opaque uAlloc(unsigned /* size */ - ); extern Opaque uCalloc(unsigned /* n */ , unsigned /* size */ ); @@ -90,7 +90,6 @@ extern Opaque uRecalloc(Opaque /* old */ , extern void uFree(Opaque /* ptr */ ); -#define uTypedAlloc(t) ((t *)uAlloc((unsigned)sizeof(t))) #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))) @@ -321,7 +321,7 @@ XkbAddFileToCache(char *name, unsigned type, char *path, void *data) return old; } } - entry = uTypedAlloc(FileCacheEntry); + entry = malloc(sizeof(FileCacheEntry)); if (entry != NULL) { *entry = (FileCacheEntry) { |