From: Yuval Kogman <nothingmuch@woobling.org>
Date: Wed, 20 Aug 2008 15:27:55 +0000 (+0000)
Subject: initialize with Newxz instead of assigning NULLs (SvREFCNT_dec in delete is safer)
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=687453c6a00d5298bb121735bbcd79c952372353;p=gitmo%2FMoose.git

initialize with Newxz instead of assigning NULLs (SvREFCNT_dec in delete is safer)
---

diff --git a/Moose.xs b/Moose.xs
index 4d334fe..136123b 100644
--- a/Moose.xs
+++ b/Moose.xs
@@ -690,17 +690,13 @@ STATIC SV *new_mi (pTHX_ HV *stash, AV *attrs) {
     MI *mi;
     const I32 num_attrs = av_len(attrs) + 1;
 
-    Newx(mi, 1, MI);
-
-    mi->attrs = NULL;
-    mi->stash = NULL;
-    mi->num_attrs = 0;
+    Newxz(mi, 1, MI);
 
     /* set the pointer now, if we have any initialization errors it'll get
      * cleaned up because obj is mortal */
     sv_setiv(sv_ptr, PTR2IV(mi));
 
-    Newx(mi->attrs, num_attrs, ATTR);
+    Newxz(mi->attrs, num_attrs, ATTR);
 
     SvREFCNT_inc_simple(stash);
     mi->stash = stash;