From 167e7529e7deece2728b9b067737f7cd31c86521 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 30 Jul 2016 18:18:07 -0400 Subject: Use calloc to allocate instances --- plugins/eg-amp.lv2/amp.c | 4 ++-- plugins/eg-fifths.lv2/fifths.c | 5 ++--- plugins/eg-sampler.lv2/sampler.c | 5 ++--- plugins/eg-sampler.lv2/sampler_ui.c | 6 +++++- 4 files changed, 11 insertions(+), 9 deletions(-) (limited to 'plugins') diff --git a/plugins/eg-amp.lv2/amp.c b/plugins/eg-amp.lv2/amp.c index 2aa39c4..4aef8d4 100644 --- a/plugins/eg-amp.lv2/amp.c +++ b/plugins/eg-amp.lv2/amp.c @@ -1,5 +1,5 @@ /* - Copyright 2006-2011 David Robillard + Copyright 2006-2016 David Robillard Copyright 2006 Steve Harris Permission to use, copy, modify, and/or distribute this software for any @@ -76,7 +76,7 @@ instantiate(const LV2_Descriptor* descriptor, const char* bundle_path, const LV2_Feature* const* features) { - Amp* amp = (Amp*)malloc(sizeof(Amp)); + Amp* amp = (Amp*)calloc(1, sizeof(Amp)); return (LV2_Handle)amp; } diff --git a/plugins/eg-fifths.lv2/fifths.c b/plugins/eg-fifths.lv2/fifths.c index 9345399..8282dd5 100644 --- a/plugins/eg-fifths.lv2/fifths.c +++ b/plugins/eg-fifths.lv2/fifths.c @@ -1,6 +1,6 @@ /* LV2 Fifths Example Plugin - Copyright 2014 David Robillard + Copyright 2014-2016 David Robillard Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -74,11 +74,10 @@ instantiate(const LV2_Descriptor* descriptor, const LV2_Feature* const* features) { // Allocate and initialise instance structure. - Fifths* self = (Fifths*)malloc(sizeof(Fifths)); + Fifths* self = (Fifths*)calloc(1, sizeof(Fifths)); if (!self) { return NULL; } - memset(self, 0, sizeof(Fifths)); // Get host features for (int i = 0; features[i]; ++i) { diff --git a/plugins/eg-sampler.lv2/sampler.c b/plugins/eg-sampler.lv2/sampler.c index 8e69bd5..38776c0 100644 --- a/plugins/eg-sampler.lv2/sampler.c +++ b/plugins/eg-sampler.lv2/sampler.c @@ -1,6 +1,6 @@ /* LV2 Sampler Example Plugin - Copyright 2011-2012 David Robillard + Copyright 2011-2016 David Robillard Copyright 2011 Gabriel M. Beddingfield Copyright 2011 James Morris @@ -258,11 +258,10 @@ instantiate(const LV2_Descriptor* descriptor, const LV2_Feature* const* features) { // Allocate and initialise instance structure. - Sampler* self = (Sampler*)malloc(sizeof(Sampler)); + Sampler* self = (Sampler*)calloc(1, sizeof(Sampler)); if (!self) { return NULL; } - memset(self, 0, sizeof(Sampler)); // Get host features for (int i = 0; features[i]; ++i) { diff --git a/plugins/eg-sampler.lv2/sampler_ui.c b/plugins/eg-sampler.lv2/sampler_ui.c index c08930a..aff7e53 100644 --- a/plugins/eg-sampler.lv2/sampler_ui.c +++ b/plugins/eg-sampler.lv2/sampler_ui.c @@ -95,7 +95,11 @@ instantiate(const LV2UI_Descriptor* descriptor, LV2UI_Widget* widget, const LV2_Feature* const* features) { - SamplerUI* ui = (SamplerUI*)malloc(sizeof(SamplerUI)); + SamplerUI* ui = (SamplerUI*)calloc(1, sizeof(SamplerUI)); + if (!ui) { + return NULL; + } + ui->map = NULL; ui->write = write_function; ui->controller = controller; -- cgit v1.2.1