diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-12-10 15:33:17 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-12-11 15:36:06 -0800 |
commit | 1fb639c97fc28b8ed66b5553eafbbeed07e4cb09 (patch) | |
tree | 9d8da033bf81897198e4ca47b5e5b6efe4a3a90f | |
parent | 8e58b7949ab96180d60fb13f7820d6cc01c228ae (diff) |
Replace malloc()+bzero() pairs with calloc() calls
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | compat.c | 3 | ||||
-rw-r--r-- | geometry.c | 6 | ||||
-rw-r--r-- | keytypes.c | 3 | ||||
-rw-r--r-- | parseutils.c | 27 |
4 files changed, 13 insertions, 26 deletions
@@ -158,10 +158,9 @@ NextInterp(CompatInfo * info) { SymInterpInfo *si; - si = malloc(sizeof(SymInterpInfo)); + si = calloc(1, sizeof(SymInterpInfo)); if (si) { - bzero(si, sizeof(SymInterpInfo)); info->interps = (SymInterpInfo *) AddCommonInfo(&info->interps->defs, (CommonInfo *) si); @@ -699,10 +699,9 @@ NextProperty(GeometryInfo * info) { PropertyInfo *pi; - pi = malloc(sizeof(PropertyInfo)); + pi = calloc(1, sizeof(PropertyInfo)); if (pi) { - bzero(pi, sizeof(PropertyInfo)); info->props = (PropertyInfo *) AddCommonInfo(&info->props->defs, (CommonInfo *) pi); info->nProps++; @@ -776,10 +775,9 @@ NextShape(GeometryInfo * info) { ShapeInfo *si; - si = malloc(sizeof(ShapeInfo)); + si = calloc(1, sizeof(ShapeInfo)); if (si) { - bzero(si, sizeof(ShapeInfo)); info->shapes = (ShapeInfo *) AddCommonInfo(&info->shapes->defs, (CommonInfo *) si); info->nShapes++; @@ -240,10 +240,9 @@ NextKeyType(KeyTypesInfo * info) { KeyTypeInfo *type; - type = malloc(sizeof(KeyTypeInfo)); + type = calloc(1, sizeof(KeyTypeInfo)); if (type != NULL) { - bzero(type, sizeof(KeyTypeInfo)); type->defs.fileID = info->fileID; type->dpy = info->dpy; info->types = (KeyTypeInfo *) AddCommonInfo(&info->types->defs, diff --git a/parseutils.c b/parseutils.c index 5c70f81..3ae7de0 100644 --- a/parseutils.c +++ b/parseutils.c @@ -451,10 +451,9 @@ ShapeDeclCreate(Atom name, OutlineDef * outlines) { ShapeDef *shape; - shape = malloc(sizeof(ShapeDef)); + shape = calloc(1, sizeof(ShapeDef)); if (shape != NULL) { - bzero(shape, sizeof(ShapeDef)); *shape = (ShapeDef) { .common.stmtType = StmtShapeDef, .common.next = NULL, @@ -478,10 +477,9 @@ OutlineCreate(Atom field, ExprDef * points) { OutlineDef *outline; - outline = malloc(sizeof(OutlineDef)); + outline = calloc(1, sizeof(OutlineDef)); if (outline != NULL) { - bzero(outline, sizeof(OutlineDef)); *outline = (OutlineDef) { .common.stmtType = StmtOutlineDef, .common.next = NULL, @@ -506,10 +504,9 @@ KeyDeclCreate(char *name, ExprDef * expr) { KeyDef *key; - key = malloc(sizeof(KeyDef)); + key = calloc(1, sizeof(KeyDef)); if (key != NULL) { - bzero(key, sizeof(KeyDef)); *key = (KeyDef) { .common.stmtType = StmtKeyDef, .common.next = NULL, @@ -537,10 +534,9 @@ RowDeclCreate(KeyDef * keys) { RowDef *row; - row = malloc(sizeof(RowDef)); + row = calloc(1, sizeof(RowDef)); if (row != NULL) { - bzero(row, sizeof(RowDef)); *row = (RowDef) { .common.stmtType = StmtRowDef, .common.next = NULL, @@ -561,10 +557,9 @@ SectionDeclCreate(Atom name, RowDef * rows) { SectionDef *section; - section = malloc(sizeof(SectionDef)); + section = calloc(1, sizeof(SectionDef)); if (section != NULL) { - bzero(section, sizeof(SectionDef)); *section = (SectionDef) { .common.stmtType = StmtSectionDef, .common.next = NULL, @@ -586,10 +581,9 @@ OverlayKeyCreate(char *under, char *over) { OverlayKeyDef *key; - key = malloc(sizeof(OverlayKeyDef)); + key = calloc(1, sizeof(OverlayKeyDef)); if (key != NULL) { - bzero(key, sizeof(OverlayKeyDef)); *key = (OverlayKeyDef) { .common.stmtType = StmtOverlayKeyDef }; @@ -606,10 +600,9 @@ OverlayDeclCreate(Atom name, OverlayKeyDef * keys) { OverlayDef *ol; - ol = malloc(sizeof(OverlayDef)); + ol = calloc(1, sizeof(OverlayDef)); if (ol != NULL) { - bzero(ol, sizeof(OverlayDef)); *ol = (OverlayDef) { .common.stmtType = StmtOverlayDef, .name = name, @@ -629,10 +622,9 @@ DoodadCreate(unsigned type, Atom name, VarDef * body) { DoodadDef *doodad; - doodad = malloc(sizeof(DoodadDef)); + doodad = calloc(1, sizeof(DoodadDef)); if (doodad != NULL) { - bzero(doodad, sizeof(DoodadDef)); *doodad = (DoodadDef) { .common.stmtType = StmtDoodadDef, .common.next = NULL, @@ -857,11 +849,10 @@ CreateXKBFile(int type, char *name, ParseCommon * defs, unsigned flags) XkbFile *file; static int fileID; - file = malloc(sizeof(XkbFile)); + file = calloc(1, sizeof(XkbFile)); if (file) { XkbEnsureSafeMapName(name); - bzero(file, sizeof(XkbFile)); *file = (XkbFile) { .type = type, .topName = uStringDup(name), |