aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjdl <x75@users.sourceforge.net>2004-01-26 20:14:47 +0000
committerjdl <x75@users.sourceforge.net>2004-01-26 20:14:47 +0000
commit6f58df1602bc981858c874a55c73dab0e76258cc (patch)
tree77220b933dd7544a9d8ef84093dc7d5a6f0612a0 /src
parentde86cb7754d773a2dba3ae92eb0dfc4cb9d77cbd (diff)
catch emtpy arrays in arbran_bang and arbran_pdfscale
svn path=/trunk/externals/maxlib/; revision=1295
Diffstat (limited to 'src')
-rw-r--r--src/arbran.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/arbran.c b/src/arbran.c
index b4e4b2c..cb39963 100644
--- a/src/arbran.c
+++ b/src/arbran.c
@@ -23,8 +23,8 @@
/* Based on PureData by Miller Puckette and others. */
/* */
/* ---------------------------------------------------------------------------- */
-
-#include "m_pd.h"
+
+#include "m_pd.h"
#include <stdlib.h>
#include <time.h>
#include <math.h>
@@ -33,11 +33,11 @@
#ifndef M_PI
#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 ------------------------------ */
static t_class *rand_arbran_class;
@@ -58,7 +58,14 @@ static void rand_arbran_pdfscale(t_rand_arbran *x)
t_int k = 0;
t_float *tx, *tp;
t_int ix, ip;
- if (!garray_getfloatarray(bx, &ix, &tx))
+
+ if(!bx || !bp)
+ {
+ post("arbran: no arrays: pdfscale!");
+ return;
+ }
+
+ if (!garray_getfloatarray(bx, &ix, &tx))
{
post("arbran: couldn't read from array!");
return;
@@ -87,11 +94,19 @@ static void rand_arbran_bang(t_rand_arbran *x)
t_int k = 0;
t_float *tx, *tp;
t_int ix, ip;
- if (!garray_getfloatarray(bx, &ix, &tx))
+
+ 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))
{
post("arbran: couldn't read from array!");
@@ -158,9 +173,10 @@ static void *rand_arbran_new(t_symbol *s1, t_symbol *s2)
t_rand_arbran *x = (t_rand_arbran *)pd_new(rand_arbran_class);
srand( (unsigned)time( NULL ) );
outlet_new(&x->x_obj, &s_float);
- x->x_x = s1;
- x->x_p = s2;
- rand_arbran_set(x);
+ rand_arbran_setarrays(x, s1, s2);
+ /* x->x_x = s1;
+ x->x_p = s2;
+ rand_arbran_set(x); */
return (x);
}