Update of /cvsroot/pure-data/externals/maxlib/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11143/src
Modified Files: arbran.c Log Message: catch emtpy arrays in arbran_bang and arbran_pdfscale
Index: arbran.c =================================================================== RCS file: /cvsroot/pure-data/externals/maxlib/src/arbran.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** arbran.c 29 Aug 2003 13:53:50 -0000 1.3 --- arbran.c 26 Jan 2004 20:14:47 -0000 1.4 *************** *** 24,29 **** /* */ /* ---------------------------------------------------------------------------- */ ! ! #include "m_pd.h" #include <stdlib.h> #include <time.h> --- 24,29 ---- /* */ /* ---------------------------------------------------------------------------- */ ! ! #include "m_pd.h" #include <stdlib.h> #include <time.h> *************** *** 34,42 **** #define M_PI 3.1415927 #endif ! static char *version = "arbran v0.1b, generates a random variable that conforms to the\n" " piecewise probability density in two arrays\n" " written by Olaf Matthes olaf.matthes@gmx.de"; ! /* -------------------------- rand_arbran ------------------------------ */
--- 34,42 ---- #define M_PI 3.1415927 #endif ! static char *version = "arbran v0.1b, generates a random variable that conforms to the\n" " piecewise probability density in two arrays\n" " written by Olaf Matthes olaf.matthes@gmx.de"; ! /* -------------------------- rand_arbran ------------------------------ */
*************** *** 59,63 **** t_float *tx, *tp; t_int ix, ip; ! if (!garray_getfloatarray(bx, &ix, &tx)) { post("arbran: couldn't read from array!"); --- 59,70 ---- t_float *tx, *tp; t_int ix, ip; ! ! if(!bx || !bp) ! { ! post("arbran: no arrays: pdfscale!"); ! return; ! } ! ! if (!garray_getfloatarray(bx, &ix, &tx)) { post("arbran: couldn't read from array!"); *************** *** 88,96 **** t_float *tx, *tp; t_int ix, ip; ! if (!garray_getfloatarray(bx, &ix, &tx)) { post("arbran: couldn't read from array!"); return; } if (!garray_getfloatarray(bp, &ip, &tp)) { --- 95,111 ---- t_float *tx, *tp; t_int ix, ip; ! ! if(!bx || !bp) ! { ! post("arbran: no arrays: bang!"); ! return; ! } ! ! if (!garray_getfloatarray(bx, &ix, &tx)) { post("arbran: couldn't read from array!"); return; } + if (!garray_getfloatarray(bp, &ip, &tp)) { *************** *** 159,165 **** srand( (unsigned)time( NULL ) ); outlet_new(&x->x_obj, &s_float); ! x->x_x = s1; ! x->x_p = s2; ! rand_arbran_set(x); return (x); } --- 174,181 ---- srand( (unsigned)time( NULL ) ); outlet_new(&x->x_obj, &s_float); ! rand_arbran_setarrays(x, s1, s2); ! /* x->x_x = s1; ! x->x_p = s2; ! rand_arbran_set(x); */ return (x); }