Jit matrix allocation question

mudang's icon

Hi,

I'm writing a jitter external, which receives network data when banged and outputs 4 different jitter matrixes filled with the data.

I've followed the jit.noise example - but my output matrixes need to have different dimsizes.

So the question is: how do I correctly initialize/set the matrixes ?

At the moment i'm calling

max_jit_mop_setup_simple(x,o,argc,argv);
max_jit_attr_args(x,argc,argv);

in the max wrapper new method. (without setting any args in max)

In the jitter init method I call jit_mop_output_nolink for all outputs.

And in the jitter matrix_calc method:
(code reduced to one output matrix)

out_skel_matrix     = jit_object_method(outputs,_jit_sym_getindex,0);

    if (x && out_skel_matrix) {
        out_savelock_skel = (long) jit_object_method(out_skel_matrix,_jit_sym_lock,1);

jit_object_method(out_skel_matrix,_jit_sym_getinfo,&skeleton_minfo);

skeleton_minfo.planecount=5;
skeleton_minfo.dimcount=1;
skeleton_minfo.dim[0]=MAXSKELETONJOINTS*MAXCAMS;
skeleton_minfo.type=_jit_sym_float32;

jit_object_method(out_skel_matrix, _jit_sym_setinfo, &skeleton_minfo);
jit_object_method(out_skel_matrix, _jit_sym_getinfo, &skeleton_minfo); // this is necessary for some reason
[..fill matrixes with data..]

Is this the correct way to do this?
I'm asking because I get random crashes and corrupted patches. Seems like the external is overwriting memory beyond boundaries :(

Thanks for any comment!