Alexandre Julliard : wmc: xmalloc shouldn't initialize to zero, do that explicitly where needed.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Aug 28 05:09:12 CDT 2006


Module: wine
Branch: master
Commit: 1659f53c3a2c972879c95f1cf6868a812ea0b324
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=1659f53c3a2c972879c95f1cf6868a812ea0b324

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Sat Aug 26 21:29:13 2006 +0200

wmc: xmalloc shouldn't initialize to zero, do that explicitly where needed.

---

 tools/wmc/mcy.y   |   10 +++++++---
 tools/wmc/utils.c |    7 +------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/tools/wmc/mcy.y b/tools/wmc/mcy.y
index db4945d..61b7fd1 100644
--- a/tools/wmc/mcy.y
+++ b/tools/wmc/mcy.y
@@ -389,7 +389,7 @@ lines	: tLINE		{ $$ = $1; }
 /*----------------------------------------------------------------------
  * Helper rules
  */
-token	: tIDENT	{ $$ = xmalloc(sizeof(token_t)); $$->name = $1; }
+token	: tIDENT	{ $$ = xmalloc(sizeof(token_t)); memset($$,0,sizeof(*$$)); $$->name = $1; }
 	| tTOKEN	{ $$ = $1; }
 	;
 
@@ -451,7 +451,10 @@ static msg_t *add_lanmsg(msg_t *msg, lan
 {
 	int i;
 	if(!msg)
+	{
 		msg = xmalloc(sizeof(msg_t));
+		memset( msg, 0, sizeof(*msg) );
+	}
 	msg->msgs = xrealloc(msg->msgs, (msg->nmsgs+1) * sizeof(*(msg->msgs)));
 	msg->msgs[msg->nmsgs] = lanmsg;
 	msg->nmsgs++;
@@ -489,7 +492,8 @@ static msg_t *complete_msg(msg_t *mp, in
 
 static void add_node(node_e type, void *p)
 {
-	node_t *ndp = (node_t *)xmalloc(sizeof(node_t));
+	node_t *ndp = xmalloc(sizeof(node_t));
+	memset( ndp, 0, sizeof(*ndp) );
 	ndp->type = type;
 	ndp->u.all = p;
 
@@ -601,7 +605,7 @@ static lan_blk_t *block_messages(node_t 
 	for(nl = 0; nl < msgtab[0]->nmsgs; nl++)	/* This should be equal for all after check_languages() */
 	{
 		lbp = xmalloc(sizeof(lan_blk_t));
-
+		memset( lbp, 0, sizeof(*lbp) );
 		if(!lblktail)
 		{
 			lblkhead = lblktail = lbp;
diff --git a/tools/wmc/utils.c b/tools/wmc/utils.c
index 6b7769e..c91902d 100644
--- a/tools/wmc/utils.c
+++ b/tools/wmc/utils.c
@@ -148,12 +148,7 @@ void *xmalloc(size_t size)
     {
 	error("Virtual memory exhausted.\n");
     }
-    /*
-     * We set it to 0.
-     * This is *paramount* because we depend on it
-     * just about everywhere in the rest of the code.
-     */
-    memset(res, 0, size);
+    memset(res, 0x55, size);
     return res;
 }
 




More information about the wine-cvs mailing list