summaryrefslogtreecommitdiff
path: root/cint_array.c
diff options
context:
space:
mode:
authorAndrew J. Schorr <aschorr@telemetry-investments.com>2017-06-22 08:26:27 -0400
committerAndrew J. Schorr <aschorr@telemetry-investments.com>2017-06-22 08:26:27 -0400
commit288b15d0793936fa14b51ed860056f6ce6200c52 (patch)
tree5de9e9dca8b30e8d168da8661ae88e3ffe2504a3 /cint_array.c
parentb7d8b6ebcd5dd714bc21acf7637d9a651e2f7ea7 (diff)
downloadgawk-288b15d0793936fa14b51ed860056f6ce6200c52.tar.gz
Replace malloc+memset with calloc, mostly by using the new ezalloc macro.
Diffstat (limited to 'cint_array.c')
-rw-r--r--cint_array.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/cint_array.c b/cint_array.c
index 092ce88a..851e980e 100644
--- a/cint_array.c
+++ b/cint_array.c
@@ -228,8 +228,7 @@ cint_lookup(NODE *symbol, NODE *subs)
assert(symbol->table_size == 0);
/* nodes[0] .. nodes[NHAT- 1] not used */
- emalloc(symbol->nodes, NODE **, INT32_BIT * sizeof(NODE *), "cint_lookup");
- memset(symbol->nodes, '\0', INT32_BIT * sizeof(NODE *));
+ ezalloc(symbol->nodes, NODE **, INT32_BIT * sizeof(NODE *), "cint_lookup");
}
symbol->table_size++; /* one more element in array */
@@ -387,8 +386,7 @@ cint_copy(NODE *symbol, NODE *newsymb)
assert(symbol->nodes != NULL);
/* allocate new table */
- emalloc(new, NODE **, INT32_BIT * sizeof(NODE *), "cint_copy");
- memset(new, '\0', INT32_BIT * sizeof(NODE *));
+ ezalloc(new, NODE **, INT32_BIT * sizeof(NODE *), "cint_copy");
old = symbol->nodes;
for (i = NHAT; i < INT32_BIT; i++) {
@@ -754,8 +752,7 @@ tree_lookup(NODE *symbol, NODE *tree, long k, int m, long base)
actual_size /= 2;
tree->flags |= HALFHAT;
}
- emalloc(table, NODE **, actual_size * sizeof(NODE *), "tree_lookup");
- memset(table, '\0', actual_size * sizeof(NODE *));
+ ezalloc(table, NODE **, actual_size * sizeof(NODE *), "tree_lookup");
tree->nodes = table;
} else
size = tree->array_size;
@@ -928,8 +925,7 @@ tree_copy(NODE *newsymb, NODE *tree, NODE *newtree)
if ((tree->flags & HALFHAT) != 0)
hsize /= 2;
- emalloc(new, NODE **, hsize * sizeof(NODE *), "tree_copy");
- memset(new, '\0', hsize * sizeof(NODE *));
+ ezalloc(new, NODE **, hsize * sizeof(NODE *), "tree_copy");
newtree->nodes = new;
newtree->array_base = tree->array_base;
newtree->array_size = tree->array_size;
@@ -1047,8 +1043,7 @@ leaf_lookup(NODE *symbol, NODE *array, long k, long size, long base)
array->table_size = 0; /* sanity */
array->array_size = size;
array->array_base = base;
- emalloc(array->nodes, NODE **, size * sizeof(NODE *), "leaf_lookup");
- memset(array->nodes, '\0', size * sizeof(NODE *));
+ ezalloc(array->nodes, NODE **, size * sizeof(NODE *), "leaf_lookup");
symbol->array_capacity += size;
}
@@ -1127,8 +1122,7 @@ leaf_copy(NODE *newsymb, NODE *array, NODE *newarray)
long size, i;
size = array->array_size;
- emalloc(new, NODE **, size * sizeof(NODE *), "leaf_copy");
- memset(new, '\0', size * sizeof(NODE *));
+ ezalloc(new, NODE **, size * sizeof(NODE *), "leaf_copy");
newarray->nodes = new;
newarray->array_size = size;
newarray->array_base = array->array_base;