Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Can't install Text::Metaphone with Strawberry Perl

by BrowserUk (Patriarch)
on Oct 15, 2008 at 14:35 UTC ( #717239=note: print w/replies, xml ) Need Help??


in reply to Can't install Text::Metaphone with Strawberry Perl

Tweak Metaphone.xs by adding #undef free as shown below, and the problem will probably go away:

#include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "metaphone.h" MODULE = Text::Metaphone PACKAGE = Text::Metaphone PROTOTYPES: ENABLE SV * Metaphone(word, ...) char* word PROTOTYPE: $;$ PREINIT: int max_length = 0; INIT: char* phoned_word; CODE: if( items > 1 ) { max_length = SvIV(ST(1)); } metaphone(word, max_length, &phoned_word); RETVAL = newSVpv(phoned_word, 0); #undef free free(phoned_word); OUTPUT: RETVAL

If this works for you, contact the module author and suggest the change to him.

Rational: The memory being freed is allocated using the C-runtime's malloc(), but the XS environment redefines free() to use it's idea of what that function should be, and it is in that redirected function things go awry. (Which is totally bogus because they haveSafefree() for memory allocated by the Perl allocator.)

By using #undef free before calling it, you get back the CRT free, and the error message and subsequent traps go away (in those cases I've tried).


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Can't install Text::Metaphone with Strawberry Perl
by Taulmarill (Deacon) on Oct 15, 2008 at 14:58 UTC
    Works for me, thank you.

    I've also posted a reply on RT describing what solves this and linking to this thread.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://717239]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2023-03-29 06:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (70 votes). Check out past polls.

    Notices?