From e5cee113af80002688d177ea3045ec7cd6f9a922 Mon Sep 17 00:00:00 2001 From: Martin Nilsson <nilsson@opera.com> Date: Sun, 27 Apr 2014 23:16:35 +0200 Subject: [PATCH] Use xcalloc instead of xalloc, and avoid doing as much initializations when the memory is already cleared. --- src/mapping.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/mapping.c b/src/mapping.c index c634dac99c..9ef3296657 100644 --- a/src/mapping.c +++ b/src/mapping.c @@ -199,13 +199,11 @@ static void init_mapping(struct mapping *m, e=MAPPING_DATA_SIZE(hashsize, size); - md=(struct mapping_data *)xalloc(e); + md=xcalloc(1,e); m->data=md; md->hashsize=hashsize; - - MEMSET((char *)md->hash, 0, sizeof(struct keypair *) * md->hashsize); - + md->free_list=MD_KEYPAIRS(md, hashsize); #ifndef PIKE_MAPPING_KEYPAIR_LOOP for(e=1;e<size;e++) @@ -214,20 +212,20 @@ static void init_mapping(struct mapping *m, mark_free_svalue (&md->free_list[e-1].ind); mark_free_svalue (&md->free_list[e-1].val); } - md->free_list[e-1].next=0; + /* md->free_list[e-1].next=0; */ mark_free_svalue (&md->free_list[e-1].ind); mark_free_svalue (&md->free_list[e-1].val); #endif /* !PIKE_MAPPING_KEYPAIR_LOOP */ - md->ind_types = 0; - md->val_types = 0; + /* md->ind_types = 0; */ + /* md->val_types = 0; */ md->flags = flags; - md->size = 0; - md->refs=0; + /* md->size = 0; */ + /* md->refs=0; */ #ifdef ATOMIC_SVALUE md->ref_type = T_MAPPING_DATA; #endif - md->valrefs=0; - md->hardlinks=0; + /* md->valrefs=0; */ + /* md->hardlinks=0; */ md->num_keypairs=size; }else{ switch (flags & MAPPING_WEAK) { -- GitLab