From a15e33171bfa06d18a4629156898979b49a2fcb8 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 22 Nov 2006 11:13:17 +0000 Subject: [PATCH] Added a few memset for structures that are later written to disk. This makes valgind happy on platforms which aligns members in structs. --- index/recindex.c | 8 +++++++- index/zinfo.c | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/index/recindex.c b/index/recindex.c index 00c9c95..c11b136 100644 --- a/index/recindex.c +++ b/index/recindex.c @@ -1,4 +1,4 @@ -/* $Id: recindex.c,v 1.54 2006-11-21 22:17:49 adam Exp $ +/* $Id: recindex.c,v 1.55 2006-11-22 11:13:17 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -202,6 +202,8 @@ static ZEBRA_RES rec_delete_single(Records p, Record rec) { struct record_index_entry entry; + /* all data in entry must be reset, since it's written verbatim */ + memset(&entry, '\0', sizeof(entry)); if (rec_release_blocks(p, rec_sysno_to_int(rec->sysno)) != ZEBRA_OK) return ZEBRA_FAIL; @@ -221,6 +223,9 @@ static ZEBRA_RES rec_write_tmp_buf(Records p, int size, zint *sysnos) int dst_type = 0; int i; + /* all data in entry must be reset, since it's written verbatim */ + memset(&entry, '\0', sizeof(entry)); + for (i = 1; i= p->head.block_move[i]) dst_type = i; @@ -279,6 +284,7 @@ Records rec_open(BFiles bfs, int rw, int compression_method) ZEBRA_RES ret = ZEBRA_OK; p = (Records) xmalloc(sizeof(*p)); + memset(&p->head, '\0', sizeof(p->head)); p->compression_method = compression_method; p->rw = rw; p->tmp_size = 1024; diff --git a/index/zinfo.c b/index/zinfo.c index 8e4f087..f98b2b4 100644 --- a/index/zinfo.c +++ b/index/zinfo.c @@ -1,4 +1,4 @@ -/* $Id: zinfo.c,v 1.72 2006-11-21 22:17:49 adam Exp $ +/* $Id: zinfo.c,v 1.73 2006-11-22 11:13:17 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -1611,6 +1611,8 @@ RecordAttr *rec_init_attr (ZebraExplainInfo zei, Record rec) if (rec->info[recInfo_attr]) return (RecordAttr *) rec->info[recInfo_attr]; recordAttr = (RecordAttr *) xmalloc (sizeof(*recordAttr)); + + memset(recordAttr, '\0', sizeof(*recordAttr)); rec->info[recInfo_attr] = (char *) recordAttr; rec->size[recInfo_attr] = sizeof(*recordAttr); -- 1.7.10.4