Changeset e11c14d4 for src


Ignore:
Timestamp:
Dec 29, 2021, 5:51:41 PM (3 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/cnn, feature/crepe
Children:
1fe822d
Parents:
808c6ac5
git-author:
Paul Brossier <piem@piem.org> (12/30/18 15:24:23)
git-committer:
Paul Brossier <piem@piem.org> (12/29/21 17:51:41)
Message:

[fmat] ensure contiguous memory

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/fmat.c

    r808c6ac5 re11c14d4  
    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.