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

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


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

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

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

---

 tools/wrc/genres.c   |    1 +
 tools/wrc/newstruc.c |    3 +++
 tools/wrc/newstruc.h |    4 +++-
 tools/wrc/parser.y   |    3 +++
 tools/wrc/utils.c    |    7 +------
 5 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/tools/wrc/genres.c b/tools/wrc/genres.c
index afce7d9..bb46d98 100644
--- a/tools/wrc/genres.c
+++ b/tools/wrc/genres.c
@@ -51,6 +51,7 @@ res_t *new_res(void)
 	r = (res_t *)xmalloc(sizeof(res_t));
 	r->allocsize = RES_BLOCKSIZE;
 	r->size = 0;
+	r->dataidx = 0;
 	r->data = (char *)xmalloc(RES_BLOCKSIZE);
 	return r;
 }
diff --git a/tools/wrc/newstruc.c b/tools/wrc/newstruc.c
index c729a59..6035608 100644
--- a/tools/wrc/newstruc.c
+++ b/tools/wrc/newstruc.c
@@ -76,6 +76,7 @@ __NEW_STRUCT_FUNC(ani_any)
 resource_t *new_resource(enum res_e t, void *res, int memopt, language_t *lan)
 {
 	resource_t *r = (resource_t *)xmalloc(sizeof(resource_t));
+	memset( r, 0, sizeof(*r) );
 	r->type = t;
 	r->res.overlay = res;
 	r->memopt = memopt;
@@ -1145,6 +1146,7 @@ stringtable_t *new_stringtable(lvc_t *lv
 {
 	stringtable_t *stt = (stringtable_t *)xmalloc(sizeof(stringtable_t));
 
+	memset( stt, 0, sizeof(*stt) );
 	if(lvc)
 		stt->lvc = *lvc;
 
@@ -1154,6 +1156,7 @@ stringtable_t *new_stringtable(lvc_t *lv
 toolbar_t *new_toolbar(int button_width, int button_height, toolbar_item_t *items, int nitems)
 {
 	toolbar_t *tb = (toolbar_t *)xmalloc(sizeof(toolbar_t));
+	memset( tb, 0, sizeof(*tb) );
 	tb->button_width = button_width;
 	tb->button_height = button_height;
 	tb->nitems = nitems;
diff --git a/tools/wrc/newstruc.h b/tools/wrc/newstruc.h
index 299782c..2e46b14 100644
--- a/tools/wrc/newstruc.h
+++ b/tools/wrc/newstruc.h
@@ -26,7 +26,9 @@ #include "wrctypes.h"
 #define __NEW_STRUCT_FUNC(p)	\
 	p##_t *new_##p(void)\
 	{\
-		return (p##_t *)xmalloc(sizeof(p##_t));\
+		p##_t * ret = xmalloc(sizeof(*ret)); \
+		memset( ret, 0, sizeof(*ret) ); \
+		return ret; \
 	}
 
 #define __NEW_STRUCT_PROTO(p)	p##_t *new_##p(void)
diff --git a/tools/wrc/parser.y b/tools/wrc/parser.y
index 252606c..a903823 100644
--- a/tools/wrc/parser.y
+++ b/tools/wrc/parser.y
@@ -2286,6 +2286,7 @@ static event_t *add_string_event(string_
 static itemex_opt_t *new_itemex_opt(int id, int type, int state, int helpid)
 {
 	itemex_opt_t *opt = (itemex_opt_t *)xmalloc(sizeof(itemex_opt_t));
+	memset( opt, 0, sizeof(*opt) );
 	opt->id = id;
 	opt->type = type;
 	opt->state = state;
@@ -2602,6 +2603,7 @@ static resource_t *build_stt_resources(s
 		{
 			newstt = new_stringtable(&stt->lvc);
 			newstt->entries = (stt_entry_t *)xmalloc(16 * sizeof(stt_entry_t));
+			memset( newstt->entries, 0, 16 * sizeof(stt_entry_t) );
 			newstt->nentries = 16;
 			newstt->idbase = stt->entries[i].id & ~0xf;
 			for(j = 0; j < 16 && i < stt->nentries; j++)
@@ -2823,6 +2825,7 @@ static resource_t *build_fontdirs(resour
 
 	/* Copy space */
 	lanfnt = xmalloc(nfnt * sizeof(*lanfnt));
+	memset( lanfnt, 0, nfnt * sizeof(*lanfnt));
 
 	/* Get all fonts covered by fontdirs */
 	for(i = 0; i < nfnd; i++)
diff --git a/tools/wrc/utils.c b/tools/wrc/utils.c
index f0e2932..d8ab8e9 100644
--- a/tools/wrc/utils.c
+++ b/tools/wrc/utils.c
@@ -168,12 +168,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