how to free atom_alloc_array () ?

Aug 18, 2009 at 5:52am

how to free atom_alloc_array () ?

Hello maxers,

just to be sure ;

t_atom *ptr ;
atom_alloc_array (SIZE, &ac, &ptr, &alloc) ;
object_free (ptr) ;

is it good, or do i have to free all t_atom allocated one by one ?

#45142
Aug 18, 2009 at 6:34am

That pointer is not an object!

sysmem_freeptr(ptr);

is what you want. But you’re also missing a couple of things.

Here’s a more comprehensive version:

{
  long ac = 0;
  t_atom *av = NULL; // THIS IS IMPORTANT! Init ac && av to 0.
  char alloc;

  if (atom_alloc_array(SIZE, &ac, &av, &alloc) == MAX_ERR_NONE) {
    // do something
    sysmem_freeptr(av);
  }
}
#162648
Aug 18, 2009 at 4:07pm

hello,

I wasn’t sure than *ptr have to be NULL ; thanks to clear that ; and of course t_atom is not object…

Merci encore.

#162649

You must be logged in to reply to this topic.