Changeset 1fcd392 for src


Ignore:
Timestamp:
Dec 30, 2018, 3:24:23 PM (6 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/cnn_org, feature/crepe_org
Children:
4c33f81
Parents:
c1c3a99
Message:

[fmat] ensure contiguous memory

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/fmat.c

    rc1c3a99 r1fcd392  
    2424fmat_t * new_fmat (uint_t height, uint_t length) {
    2525  fmat_t * s;
    26   uint_t i,j;
     26  uint_t i;
    2727  if ((sint_t)length <= 0 || (sint_t)height <= 0 ) {
    2828    return NULL;
     
    3232  s->length = length;
    3333  s->data = AUBIO_ARRAY(smpl_t*,s->height);
    34   for (i=0; i< s->height; i++) {
    35     s->data[i] = AUBIO_ARRAY(smpl_t, s->length);
    36     for (j=0; j< s->length; j++) {
    37       s->data[i][j]=0.;
    38     }
     34  s->data[0] = AUBIO_ARRAY(smpl_t, s->length * s->height);
     35  for (i=1; i< s->height; i++) {
     36    s->data[i] = s->data[0] + i * s->length;
    3937  }
    4038  return s;
     
    4240
    4341void del_fmat (fmat_t *s) {
    44   uint_t i;
    45   for (i=0; i<s->height; i++) {
    46     AUBIO_FREE(s->data[i]);
    47   }
    48   AUBIO_FREE(s->data);
     42  AUBIO_ASSERT(s);
     43  if (s->data[0])
     44    AUBIO_FREE(s->data[0]);
     45  if (s->data)
     46    AUBIO_FREE(s->data);
    4947  AUBIO_FREE(s);
    5048}
Note: See TracChangeset for help on using the changeset viewer.