Here is the entries for the foo function that I have:
extern bool foo( char *, char **);
static int
not_here(char *s)
{
croak("%s not implemented on this arch.", s);
return -1;
}
static double
constant(char *name, int len, int arg)
{
errno = EINVAL;
return 0;
}
MODULE = api PACKAGE = api
bool
foo( in, out )
char * in
char *& out
OUTPUT:
out
RETVAL
eof
Do I need to add a CODE: section?
something like:
CODE:
RETVAL = foo( in, out );
free( out );
Jerry
-----Original Message-----
From: Tye McQueen [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 14, 2002 10:17 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: Question about memory management
Excerpts from the mail message of Jerry Beckmann:
)
) I am having some problems with memory management with using a C library.
The
) library has basically 1 function that I use. The function is foo( char*
) input, char** output). The problem is that output seems to not be freed by
) the perl xs module, and I get scripts that grow to 50+MBs very quickly.
[...]
) A sample perl function that I have using it looks like:
The problem isn't the Perl subroutine but the XS subroutine.
) Any ideas on how I can free the memory that this library is allocating?
Yeah, add free(output) to your XS subroutine.
You don't show the XS code, but I'll bet the XS code is copying
the output string (that is about all Perl will allow since Perl
only deals with buffers that it has allocated itself). So you
need to free the original output string after that.
Tye