May 21 2010 | 12:10 pm

Hi everybody,

I've a problem that I can't solve, although the help of colleagues and university mates. I hope in your support. This is for my thesis's training, please! :)

In my perform routine I need to save in a vector the samples to make some stuff (interpolation). No problem: I allocate the memory I need...

The problem is that i cannot succeed in compiling the following code due to the allocation of memory. In fact the C pointer and the malloc instruction are ok, but if I try to compile the instructions that are in the code as a comment (the ones that work with the memory allocated) they generate "waterfall" errors on the instructions following (non-existent errors).

I cannot understand the causes of the problem. I suppose it's not for the MaxMSP's library, a C mistake, so what would be the problem???

Here's the code:

[code]

t_int *distexp_performScalar(t_int *w)

{

// w[0] &distexp_perform

t_distexp *x = (t_distexp *)(w[1]); //object's pointer

t_float *inL = (t_float *)(w[2]); //input array pointer

t_float *outL = (t_float *)(w[3]); //output array pointer

int n = (int)w[4]; //signal vector

t_float *list1samples;

list1samples = (t_float *) malloc(n*sizeof(t_float));

while (n--){ //per sample . . .

//Calculations...

t_float effecondi1 = x->fd1;

t_float esponentedik1 = 3. * effecondi1; //

[...]

t_float segno1 = sgn(input1); //

t_float result1 = segno1 * parentesi1;

//*(list1samples)= result1;

//list1samples[0] = 0.1;

//list1samples[n] = result1;

//*(list1samples+(n-1)) = result1;

//other instruction that generates errors

t_float effecondi1 = x->fd1;

t_float esponentedik1 = 3. * effecondi1;

t_float k1 = exp(esponentedik1);

t_float modulo1 = fabs(*inL);

t_float modulonegativo1 = 0 - modulo1;

[...]

}

return w + 5;

}

[/code]

Note that if i close immediately ofter the } of the while with the incriminate instructions it compiles!.

Thank you in advance :D:D:D