Martin Peach wrote:
Peter Worth wrote:
hi,
i'm writing an external that requires a lot of memory freeing when it is destroyed, but i cant find much in the way of documentation telling me how to set up a deconstructor.
at the moment i'm doing this:
extern "C" __declspec( dllexport ) void markovchain_tilde_setup(void) { markovchain_tilde_class = class_new(gensym("markovchain~"), (t_newmethod)markovchain_tilde_new, (t_method)markovchain_tilde_destroy, sizeof(t_markovchain_tilde),
[...]
}
with a deconstructor like this:
void *markovchain_tilde_destroy() { ....
hmm, why do you think that the free-method takes no arguments and is of type (void*)? i hope my oh-so-famous externals-howto does not claim such things:
"If memory is reserved dynamically, this memory has to be freed by the destructor-method _freemethod_ (without any return argument), when the object is destroyed."
Declare the deconstructor as void markovchain_tilde_destroy(t_markovchain_tilde *x) and keep pointer(s) to the disposable memory somewhere in x.
right.
btw, _please_ don't use the declspec constuction directly, as it will render your code unusable (without modifications) to non-M$VC compilers.
a far better approach would be to use conditional #define's
mfg.asder IOhannes