From 36b470397a178ca64bc6d98ecc652aaa7671c938 Mon Sep 17 00:00:00 2001
From: David Robillard <d@drobilla.net>
Date: Fri, 11 Sep 2015 19:42:02 +0000
Subject: Zero-initialize wrapper structs.

git-svn-id: http://svn.drobilla.net/lad/trunk/suil@5723 a436a847-0d15-0410-975c-d299462d15a1
---
 src/cocoa_in_gtk2.mm | 2 +-
 src/gtk2_in_qt4.cpp  | 7 ++-----
 src/qt4_in_gtk2.cpp  | 7 +++----
 src/win_in_gtk2.cpp  | 2 +-
 src/x11_in_gtk2.c    | 2 +-
 src/x11_in_qt4.cpp   | 6 ++----
 6 files changed, 10 insertions(+), 16 deletions(-)

(limited to 'src')

diff --git a/src/cocoa_in_gtk2.mm b/src/cocoa_in_gtk2.mm
index 09ca883..f2866fe 100644
--- a/src/cocoa_in_gtk2.mm
+++ b/src/cocoa_in_gtk2.mm
@@ -376,7 +376,7 @@ suil_wrapper_new(SuilHost*      host,
 		return NULL;
 	}
 
-	SuilWrapper* wrapper = (SuilWrapper*)malloc(sizeof(SuilWrapper));
+	SuilWrapper* wrapper = (SuilWrapper*)calloc(1, sizeof(SuilWrapper));
 	wrapper->wrap = wrapper_wrap;
 	wrapper->free = wrapper_free;
 
diff --git a/src/gtk2_in_qt4.cpp b/src/gtk2_in_qt4.cpp
index 731a4d8..641d1ba 100644
--- a/src/gtk2_in_qt4.cpp
+++ b/src/gtk2_in_qt4.cpp
@@ -127,10 +127,7 @@ suil_wrapper_new(SuilHost*      host,
 
 	/* Create wrapper implementation. */
 	SuilGtk2InQt4Wrapper* const impl = (SuilGtk2InQt4Wrapper*)
-		malloc(sizeof(SuilGtk2InQt4Wrapper));
-	impl->host_widget = NULL;
-	impl->parent      = NULL;
-	impl->plug        = NULL;
+		calloc(1, sizeof(SuilGtk2InQt4Wrapper));
 
 	/* Set parent widget if given. */
 	for (unsigned i = 0; i < n_features; ++i) {
@@ -139,7 +136,7 @@ suil_wrapper_new(SuilHost*      host,
 		}
 	}
 
-	SuilWrapper* wrapper = (SuilWrapper*)malloc(sizeof(SuilWrapper));
+	SuilWrapper* wrapper = (SuilWrapper*)calloc(1, sizeof(SuilWrapper));
 	wrapper->wrap = wrapper_wrap;
 	wrapper->free = wrapper_free;
 	wrapper->impl = impl;
diff --git a/src/qt4_in_gtk2.cpp b/src/qt4_in_gtk2.cpp
index d7c6225..ab58838 100644
--- a/src/qt4_in_gtk2.cpp
+++ b/src/qt4_in_gtk2.cpp
@@ -135,10 +135,9 @@ suil_wrapper_new(SuilHost*      host,
                  LV2_Feature*** features,
                  unsigned       n_features)
 {
-	SuilWrapper* wrapper = (SuilWrapper*)malloc(sizeof(SuilWrapper));
-	wrapper->wrap    = wrapper_wrap;
-	wrapper->free    = wrapper_free;
-	wrapper->impl    = NULL;
+	SuilWrapper* wrapper = (SuilWrapper*)calloc(1, sizeof(SuilWrapper));
+	wrapper->wrap = wrapper_wrap;
+	wrapper->free = wrapper_free;
 
 	SuilQtWrapper* const wrap = SUIL_QT_WRAPPER(
 		g_object_new(SUIL_TYPE_QT_WRAPPER, NULL));
diff --git a/src/win_in_gtk2.cpp b/src/win_in_gtk2.cpp
index 4cc19c1..eabc1ac 100644
--- a/src/win_in_gtk2.cpp
+++ b/src/win_in_gtk2.cpp
@@ -212,7 +212,7 @@ suil_wrapper_new(SuilHost*      host,
 		return NULL;
 	}
 
-	SuilWrapper* wrapper = (SuilWrapper*)malloc(sizeof(SuilWrapper));
+	SuilWrapper* wrapper = (SuilWrapper*)calloc(1, sizeof(SuilWrapper));
 	wrapper->wrap = wrapper_wrap;
 	wrapper->free = wrapper_free;
 
diff --git a/src/x11_in_gtk2.c b/src/x11_in_gtk2.c
index 000f600..51856e9 100644
--- a/src/x11_in_gtk2.c
+++ b/src/x11_in_gtk2.c
@@ -299,7 +299,7 @@ suil_wrapper_new(SuilHost*      host,
                  LV2_Feature*** features,
                  unsigned       n_features)
 {
-	SuilWrapper* wrapper = (SuilWrapper*)malloc(sizeof(SuilWrapper));
+	SuilWrapper* wrapper = (SuilWrapper*)calloc(1, sizeof(SuilWrapper));
 	wrapper->wrap = wrapper_wrap;
 	wrapper->free = wrapper_free;
 
diff --git a/src/x11_in_qt4.cpp b/src/x11_in_qt4.cpp
index 8880dbe..fa58fc5 100644
--- a/src/x11_in_qt4.cpp
+++ b/src/x11_in_qt4.cpp
@@ -124,11 +124,9 @@ suil_wrapper_new(SuilHost*      host,
                  unsigned       n_features)
 {
 	SuilX11InQt4Wrapper* const impl = (SuilX11InQt4Wrapper*)
-		malloc(sizeof(SuilX11InQt4Wrapper));
-	impl->host_widget = NULL;
-	impl->parent      = NULL;
+		calloc(1, sizeof(SuilX11InQt4Wrapper));
 
-	SuilWrapper* wrapper = (SuilWrapper*)malloc(sizeof(SuilWrapper));
+	SuilWrapper* wrapper = (SuilWrapper*)calloc(1, sizeof(SuilWrapper));
 	wrapper->wrap = wrapper_wrap;
 	wrapper->free = wrapper_free;
 
-- 
cgit v1.2.1