msp external in C

    Dec 09 2012 | 10:21 am
    Hello, I am writing a msp external in C and I need to know whether there is a function which is called when the object is deleted. I am using a malloc() function and I want to free the memory once the object is deleted.

    • Dec 09 2012 | 11:15 am
      Have look at simplemax example from the SDK, you'll see that in your contstuctor (class_new) you define which method is called when the instance of the object is freed.
      t_class *c = class_new("simplemax", (method)simplemax_new, (method)simplemax_free, (long)sizeof(t_simplemax), 0L /* leave NULL!! */, A_GIMME, 0);
      Note that you can also use sysmem_newptr()/sysmem_free() to alloc/dealloc memory as part of the Max SDK.