diff options
author | David Robillard <d@drobilla.net> | 2016-07-30 18:18:07 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2016-07-30 18:18:07 -0400 |
commit | 167e7529e7deece2728b9b067737f7cd31c86521 (patch) | |
tree | 297e4cd147c6d2df0cbbe546844cad99b59b9c90 /plugins | |
parent | a75a1fac59d1ea1e2c042db7cf076a30ee945933 (diff) | |
download | lv2-167e7529e7deece2728b9b067737f7cd31c86521.tar.xz |
Use calloc to allocate instances
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/eg-amp.lv2/amp.c | 4 | ||||
-rw-r--r-- | plugins/eg-fifths.lv2/fifths.c | 5 | ||||
-rw-r--r-- | plugins/eg-sampler.lv2/sampler.c | 5 | ||||
-rw-r--r-- | plugins/eg-sampler.lv2/sampler_ui.c | 6 |
4 files changed, 11 insertions, 9 deletions
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 <d@drobilla.net> + Copyright 2006-2016 David Robillard <d@drobilla.net> Copyright 2006 Steve Harris <steve@plugin.org.uk> 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 <d@drobilla.net> + Copyright 2014-2016 David Robillard <d@drobilla.net> 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 <d@drobilla.net> + Copyright 2011-2016 David Robillard <d@drobilla.net> Copyright 2011 Gabriel M. Beddingfield <gabriel@teuton.org> Copyright 2011 James Morris <jwm.art.net@gmail.com> @@ -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; |