[PD-dev] Destructor in external classes

2014-03-24 Thread Funs Seelen
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
___
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev


Re: [PD-dev] Destructor in external classes

2014-03-24 Thread IOhannes m zmölnig
On 03/24/2014 02:56 PM, Antoine Villeret wrote:
 hello,
 
 the free method seems to be called when the object is deleted from the
 canvas.
 
 is there a similar method called on Pd quit ?

no.
see http://sourceforge.net/p/pure-data/patches/82/


fgsdr
IOhannes



signature.asc
Description: OpenPGP digital signature
___
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev


Re: [PD-dev] Destructor in external classes

2014-03-24 Thread Antoine Villeret
this patch is quite old, and seems to be included in Pd-extended since
about 2 years,

is there still  a good reason to not include this patch in pd-vanilla ?

thanks anyway to point me there

regards
antoine

--
do it yourself
http://antoine.villeret.free.fr


2014-03-24 14:58 GMT+01:00 IOhannes m zmölnig zmoel...@iem.at:

 On 03/24/2014 02:56 PM, Antoine Villeret wrote:
  hello,
 
  the free method seems to be called when the object is deleted from the
  canvas.
 
  is there a similar method called on Pd quit ?

 no.
 see http://sourceforge.net/p/pure-data/patches/82/


 fgsdr
 IOhannes


 ___
 Pd-dev mailing list
 Pd-dev@iem.at
 http://lists.puredata.info/listinfo/pd-dev


___
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev


Re: [PD-dev] Destructor in external classes

2014-03-24 Thread Funs Seelen
Hello IOhannes,

On Mon, Mar 24, 2014 at 2:45 PM, IOhannes m zmölnig zmoel...@iem.at wrote:


 the destructor is called free_method in Pd-lingo and is set via
 class_new() [1].

 so you basically would do:

 void myclass_free(t_myclass*x) {
free(x-x_ptr);
 }
 // ...
 void myclass_setup(void) {
   class_new(gensym(myclass), myclass_new, myclass_free,
 sizeof(t_myclass), 0, ...);
 }


Thanks! I now see how it works. You indeed mentioned it in the tutorial.
Sorry for missing that part.

Regards.
Funs
___
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev


Re: [PD-dev] Destructor in external classes

2014-03-24 Thread Kjetil Matheussen
On Mon, Mar 24, 2014 at 2:56 PM, Antoine Villeret
antoine.ville...@gmail.com wrote:
 hello,

 the free method seems to be called when the object is deleted from the
 canvas.

 is there a similar method called on Pd quit ?
 I'm asking that because I'm rewriting a pix_openni2 object and to free the
 openni context i have to call a shutdown() function on quit and not on
 object deletion


How about 'atexit'?

___
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev


[PD-dev] pd howto errata

2014-03-24 Thread Jonathan Wilkes

Here's errata for the first part of the tutorial on building externals:

change all
pd
to
Pd

change all
``
to


http://iem.at/pd/externals-HOWTO/

change
HOWTO
to
HOW TO

change
explain, how
to
explain how

change
pdf(English)
to
pdf (English)

change
pdf(German)
to
pdf (German)

http://iem.at/pd/externals-HOWTO/node2.html

change
windos-plattforms
to
windows platforms

change
pd ist
to
pd is

change
systemdependent
to
system dependent

change
pd supports to
to
pd supports two

http://iem.at/pd/externals-HOWTO/node3.html

change
witha
to
with a

change
messagesystem
to
message system

change
and are therefore are
to
and are therefore

change
functionn
to
function

remove
Das erste Argument ist der symbolische Name der Klasse.

***
explain what order A_DEFFLOAT and A_DEFSYMBOL may appear when defining 
arguments for object or methods

***

-Jonathan

___
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev