note
BrowserUk
<blockquote><i></i></blockquote>
<p>Tweak Metaphone.xs by adding <c>#undef free</c> as shown below, and the problem will probably go away:
<code>
#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
</code>
<p>If this works for you, contact the module author and suggest the change to him.
<p>Rational: The memory being freed is allocated using the C-runtime's <c>malloc()</c>, but the XS environment redefines <c>free()</c> 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 have<c>Safefree()</c> for memory allocated by the Perl allocator.)
<p>By using <c>#undef free</c> before calling it, you get back the CRT free, and the error message and subsequent traps go away (in those cases I've tried).
<div class="pmsig"><div class="pmsig-171588">
<hr />
<font size=1 >
<div>Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.</div>
<div>"Science is about questioning the status quo. Questioning authority". </div>
<div>In the absence of evidence, opinion is indistinguishable from prejudice.</div>
<div>[http://news.bbc.co.uk/1/hi/education/6202877.stm|"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."]</div>
</font>
</div></div>
717224
717224