From: Paul Brossier Date: Tue, 29 Jan 2019 02:30:23 +0000 (+0100) Subject: [fmat] clarify memory allocation X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=668dfdd179eb6ccc31d6df05f91d1497ece85f6b;p=aubio.git [fmat] clarify memory allocation --- diff --git a/src/fmat.c b/src/fmat.c index cb1dba55..62c48c50 100644 --- a/src/fmat.c +++ b/src/fmat.c @@ -24,14 +24,16 @@ fmat_t * new_fmat (uint_t height, uint_t length) { fmat_t * s; uint_t i; - if ((sint_t)length <= 0 || (sint_t)height <= 0 ) { + if ((sint_t)height <= 0 || (sint_t)length <= 0 ) { return NULL; } s = AUBIO_NEW(fmat_t); s->height = height; s->length = length; + // array of row pointers s->data = AUBIO_ARRAY(smpl_t*,s->height); - s->data[0] = AUBIO_ARRAY(smpl_t, s->length * s->height); + // first row store the full height * length buffer + s->data[0] = AUBIO_ARRAY(smpl_t, s->height * s->length); for (i=1; i< s->height; i++) { s->data[i] = s->data[0] + i * s->length; }