summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJukka Ojanen <jukka.ojanen@linkotec.net>2015-07-06 12:02:33 +0300
committerJukka Ojanen <jukka.ojanen@linkotec.net>2015-07-06 12:02:33 +0300
commitceb8e6aef7f0e406ff4724896a8138bf72911a68 (patch)
tree0db34e9933399d437e6e1da0f5cb8d74f1ef05ae
parentb481f5980e000a4ff5e123e8165e52b6dea6ea54 (diff)
downloadffts-ceb8e6aef7f0e406ff4724896a8138bf72911a68.zip
ffts-ceb8e6aef7f0e406ff4724896a8138bf72911a68.tar.gz
Avoid allocating array of single pointer
-rw-r--r--src/ffts_real.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/ffts_real.c b/src/ffts_real.c
index 12c02b9..5522f6b 100644
--- a/src/ffts_real.c
+++ b/src/ffts_real.c
@@ -4,6 +4,7 @@ This file is part of FFTS -- The Fastest Fourier Transform in the South
Copyright (c) 2012, Anthony M. Blake <amb@anthonix.com>
Copyright (c) 2012, The University of Waikato
+Copyright (c) 2015, Jukka Ojanen <jukka.ojanen@kolumbus.fi>
All rights reserved.
@@ -40,7 +41,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <xmmintrin.h>
#endif
-static void ffts_free_1d_real(ffts_plan_t *p)
+static void
+ffts_free_1d_real(ffts_plan_t *p)
{
if (p->B) {
ffts_aligned_free(p->B);
@@ -54,9 +56,8 @@ static void ffts_free_1d_real(ffts_plan_t *p)
ffts_aligned_free(p->buf);
}
- if (p->plans) {
+ if (p->plans[0]) {
ffts_free(p->plans[0]);
- free(p->plans);
}
free(p);
@@ -207,12 +208,13 @@ static void ffts_execute_1d_real_inv(ffts_plan_t *p, const void *vin, void *vout
p->plans[0]->transform(p->plans[0], buf, out);
}
-ffts_plan_t *ffts_init_1d_real(size_t N, int sign)
+ffts_plan_t*
+ffts_init_1d_real(size_t N, int sign)
{
ffts_plan_t *p;
size_t i;
- p = (ffts_plan_t*) calloc(1, sizeof(*p));
+ p = (ffts_plan_t*) calloc(1, sizeof(*p) + sizeof(*p->plans));
if (!p) {
return NULL;
}
@@ -226,11 +228,7 @@ ffts_plan_t *ffts_init_1d_real(size_t N, int sign)
p->destroy = &ffts_free_1d_real;
p->N = N;
p->rank = 1;
-
- p->plans = (ffts_plan_t**) malloc(1 * sizeof(*p->plans));
- if (!p->plans) {
- goto cleanup;
- }
+ p->plans = (ffts_plan_t**) &p[1];
p->plans[0] = ffts_init_1d(N/2, sign);
if (!p->plans[0]) {
OpenPOWER on IntegriCloud