changeset 28810:54230bed6a34

Use a single malloc to allocate space for the circular buffers.
author reimar
date Fri, 06 Mar 2009 11:39:13 +0000
parents 5de88e6e2494
children 7c0b23a811bd
files libaf/af_resample.c
diffstat 1 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libaf/af_resample.c	Fri Mar 06 11:31:18 2009 +0000
+++ b/libaf/af_resample.c	Fri Mar 06 11:39:13 2009 +0000
@@ -181,9 +181,7 @@
 
     // Free space for circular buffers
     if(s->xq){
-      for(i=1;i<af->data->nch;i++)
-	if(s->xq[i])
-	  free(s->xq[i]);
+      free(s->xq[0]);
       free(s->xq);
       s->xq = NULL;
     }
@@ -218,8 +216,9 @@
 
     // Create space for circular buffers
     s->xq = malloc(n->nch*sizeof(void*));
-    for(i=0;i<n->nch;i++)
-      s->xq[i] = malloc(2*L*af->data->bps);
+    s->xq[0] = malloc(n->nch*2*L*af->data->bps);
+    for(i=1;i<n->nch;i++)
+      s->xq[i] = (uint8_t *)s->xq[i-1] + 2*L*af->data->bps;
     s->xi = 0;
 
     // Check if the design needs to be redone