Update of /cvsroot/pure-data/externals/zexy/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10881
Modified Files: multiplex.c Log Message: fixed a memory bug that crashed [multiplex] on construction | destruction
Index: multiplex.c =================================================================== RCS file: /cvsroot/pure-data/externals/zexy/src/multiplex.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** multiplex.c 19 May 2005 09:42:55 -0000 1.3 --- multiplex.c 16 Jun 2005 11:49:06 -0000 1.4 *************** *** 43,47 **** typedef struct _muxproxy { ! t_object p_ob; t_mux *p_master; int id; --- 43,47 ---- typedef struct _muxproxy { ! t_pd p_pd; t_mux *p_master; int id; *************** *** 65,73 **** 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 *));
for (n = 0; n<x->i_count; n++) { --- 65,73 ---- t_mux *x = (t_mux *)pd_new(mux_class); // t_muxproxy *y=(t_muxproxy*)pd_new(muxproxy_class);
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++) { *************** *** 85,89 **** --- 85,110 ----
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) }