This fixes a memory leak in the allocation of doubles, but causes 4 tests to fail
[Math-GSL.git] / swig / Randist.i
blobc51c0a60fb54455a46a058adb00ec6db9a8eafef
1 %module "Math::GSL::Randist"
2 %include "typemaps.i"
3 %include "gsl_typemaps.i"
5 void gsl_ran_dir_2d (const gsl_rng * r, double *OUTPUT, double *OUTPUT);
6 void gsl_ran_dir_2d_trig_method (const gsl_rng * r, double *OUTPUT, double *OUTPUT);
7 void gsl_ran_dir_3d (const gsl_rng * r, double *OUTPUT, double *OUTPUT, double *OUTPUT);
8 void gsl_ran_bivariate_gaussian (const gsl_rng * r, double sigma_x, double sigma_y, double rho, double *OUTPUT, double *OUTPUT);
10 %typemap(in) void * {
11 AV *tempav;
12 I32 len;
13 int i,x;
14 SV **tv;
16 if (!SvROK($input))
17 croak("Argument $argnum is not a reference.");
18 if (SvTYPE(SvRV($input)) != SVt_PVAV)
19 croak("Argument $argnum is not an array.");
21 tempav = (AV*)SvRV($input);
22 len = av_len(tempav);
23 $1 = (int **) malloc((len+2)*sizeof(int *));
24 for (i = 0; i <= len; i++) {
25 tv = av_fetch(tempav, i, 0);
26 x = SvIV(*tv);
27 memset((int*)($1+i), x , 1);
28 //printf("curr = %d\n", (int)($1+i) );
31 %typemap(freearg) void * {
32 free($1);
36 #include "gsl/gsl_randist.h"
38 %include "gsl/gsl_randist.h"
39 %include "../pod/Randist.pod"