Hello all,
While reorganizing my code a question about memory management in Pd arose in me. If I allocate memory within the constructor space, do I have to free this myself? If yes, how or where should I do this?
Example:
typedef struct _myclass {
t_object x_obj;
t_int* x_ptr;
} t_myclass;
/* constructor */
void *myclass_new(t_symbol *s, int argc, t_atom *argv)
{
t_myclass *x = (t_myclass *)pd_new(myclass_class);
x_ptr = (t_int)malloc(32*sizeof(t_int));
myFunction((int*) x_ptr);
return (void *)x;
}
Note that I still need this pointer and the memory it's pointing at in the method space.
Do I have to worry about this or is all memory freed automatically when an object is removed from its canvas?
Any hints?
Regards,
Funs