diff options
author | IOhannes m zmölnig <zmoelnig@users.sourceforge.net> | 2005-06-16 11:49:06 +0000 |
---|---|---|
committer | IOhannes m zmölnig <zmoelnig@users.sourceforge.net> | 2005-06-16 11:49:06 +0000 |
commit | 79ea7c99dcff3bc95b0d9cb8841d23c3f48ccc67 (patch) | |
tree | 7e131a17cbfc3e95c099dd30729239de186341c7 /src | |
parent | b34c664be8212a0e131ed90efe9a0d23e0abef65 (diff) |
fixed a memory bug that crashed [multiplex] on construction | destruction
svn path=/trunk/externals/zexy/; revision=3183
Diffstat (limited to 'src')
-rw-r--r-- | src/multiplex.c | 27 |
1 files 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; n<x->i_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; n<count; n++){ + if(x->in[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) |