This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Ole Myren R|hne <mrohne@mixing.uio.no> writes: > > I want to use the _init and _fini symbols to automatically > define/undefine extensions as a dynamic library is linked/unlinked. My > naive approach looks like: > > mysin.c: > #include <math.h> > #include <guile/gh.h> > SCM mysin(SCM x) {return gh_double2scm(sin(gh_scm2double(x)));} > void _init(void) {gh_new_procedure("mysin", mysin, 1, 0, 0);} > void _fini(void) {gh_eval_str("(undefine mysin)");} Hmm, off hand I would say that this doesn't work. But, obviously, it does. Strange. I would have said that using the .init/.fini sections of the ELF object format is not that simple. You would have to use global C++ objects, or some gcc extension. Any way, now that I see that it *does* work, I have to say that I don't like it. "_init" and "_fini" seem to be very magical names, but only with ELF. > Question: guile seems to leak memory each time the test is repeated. I > am looking for some `gh_delete_procedure' that guarantees that all > resources allocated by gh_new_procedure are released. Hmm, how much memory does it leak?