From 79ea7c99dcff3bc95b0d9cb8841d23c3f48ccc67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Thu, 16 Jun 2005 11:49:06 +0000 Subject: fixed a memory bug that crashed [multiplex] on construction | destruction svn path=/trunk/externals/zexy/; revision=3183 --- src/multiplex.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/multiplex.c b/src/multiplex.c index 41e87d1..ec02ae1 100644 --- a/src/multiplex.c +++ b/src/multiplex.c @@ -42,7 +42,7 @@ typedef struct _mux typedef struct _muxproxy { - t_object p_ob; + t_pd p_pd; t_mux *p_master; int id; } t_muxproxy; @@ -64,11 +64,11 @@ static void *mux_new(t_symbol *s, int argc, t_atom *argv) int n = (argc < 2)?2:argc; t_mux *x = (t_mux *)pd_new(mux_class); // t_muxproxy *y=(t_muxproxy*)pd_new(muxproxy_class); - x->x_proxy = (t_muxproxy**)getbytes(sizeof(t_muxproxy*)); x->i_selected=0; x->i_count = n; x->in = (t_inlet **)getbytes(x->i_count * sizeof(t_inlet *)); + x->x_proxy = (t_muxproxy**)getbytes(x->i_count * sizeof(t_muxproxy*)); for (n = 0; ni_count; n++) { x->x_proxy[n]=(t_muxproxy*)pd_new(muxproxy_class); @@ -84,7 +84,28 @@ static void *mux_new(t_symbol *s, int argc, t_atom *argv) } static void mux_free(t_mux*x){ - + const int count = x->i_count; + + if(x->in && x->x_proxy){ + int n=0; + for(n=0; nin[n]){ + inlet_free(x->in[n]); + } + x->in[n]=0; + if(x->x_proxy[n]){ + t_muxproxy *y=x->x_proxy[n]; + y->p_master=0; + y->id=0; + pd_free(&y->p_pd); + } + x->x_proxy[n]=0; + } + freebytes(x->in, x->i_count * sizeof(t_inlet *)); + freebytes(x->x_proxy, x->i_count * sizeof(t_muxproxy*)); + } + + //pd_free(&y->p_pd) } void multiplex_setup(void) -- cgit v1.2.1