Hi Alex,

I think the major mistake of mine was to return (char *). The correct way to avoid memory leaks is to return SV* in XS. I learned this two weeks ago :(

So the correct way would be the following:

char_ptr = malloc(required_size);
... fill it ...
SV *sv;
new_SV(sv);
sv_usepvn(sv, char_ptr, required_size);
free(char_ptr);
RETVAL = sv;

or the better way:

char_ptr = malloc(required_size);
... do something ...
RETVAL = newSVpvn(char_ptr, required_size);
free(char_ptr);

The interface would be now:

SV *
pubkey_hash (spkac, digest_name="sha1")

Perl takes care about SVs. So there should be no memory leaks.

Best regards

Michael

P.S. who fixes all the functions?
--
_______________________________________________________________

Michael Bell                    Humboldt-Universitaet zu Berlin

Tel.: +49 (0)30-2093 2482       ZE Computer- und Medienservice
Fax:  +49 (0)30-2093 2704       Unter den Linden 6
[EMAIL PROTECTED]   D-10099 Berlin
_______________________________________________________________

X.509 CA Certificates / Wurzelzertifikate

http://ra.pki.hu-berlin.de

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
OpenXPKI-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openxpki-devel

Reply via email to