develooper Front page | perl.perl5.porters | Postings from September 2009

Re: Embedding Perl but redefining its malloc()

Thread Previous | Thread Next
Steffen Mueller
September 26, 2009 03:29
Re: Embedding Perl but redefining its malloc()
Message ID:
Hi Raphael,

(Raphael Manfredi) wrote:
> Quoting Joshua ben Jore <> from ml.lang.perl.porters:
> :On Thu, Sep 24, 2009 at 3:51 PM, Raphael Manfredi
> :<> wrote:
> :> So what do I do before instantiating the perl interpretor to install
> :> my own memory management rourtines?
> :
> :Experiment til it works? Like I said, this is a perl library
> :compilation time activity so once your C macros are right, you can
> :compile perl and get it to pick up your new definitions.
> I was afraid you were going to say that.
> I do not want to recompile perl with my own macros.  I want to link with
> plain stock -lperl then use an API from the perl library to supersede the
> memory allocation routines at runtime.
> I take from your answer that this API does not exist today and would have
> to be developped in order to do what I want.

I wonder whether such an API wouldn't slow down the malloc routine 
because it would have to check for user-supplied implementations. But 
then again, I'm not known to be particularly clueful in all things C.

> Bonus question: is there a runtime routine I can call before perl_alloc()
> to give me the version of the perl library against which I've been linked?

Quoting perlvars.h:

/* These are baked at compile time into any shared perl library.
    In future 5.10.x releases this will allow us in main() to sanity 
test the
    library we're linking against.  */

PERLVARI(Grevision,     U8,     PERL_REVISION)
PERLVARI(Gversion,      U8,     PERL_VERSION)
PERLVARI(Gsubversion,   U8,     PERL_SUBVERSION)


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About