From: Jarkko Hietaniemi Date: Thu, 16 May 2002 22:54:36 +0000 (+0000) Subject: Purify: dl_last_error was leaking. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=591022fb18ce8ae85902133bbbfe8e1de05216b1;p=p5sagit%2Fp5-mst-13.2.git Purify: dl_last_error was leaking. p4raw-id: //depot/perl@16638 --- diff --git a/ext/DynaLoader/dlutils.c b/ext/DynaLoader/dlutils.c index 620d31b..2bd73ad 100644 --- a/ext/DynaLoader/dlutils.c +++ b/ext/DynaLoader/dlutils.c @@ -14,7 +14,7 @@ #define MY_CXT_KEY "DynaLoader::_guts" XS_VERSION typedef struct { - char * x_dl_last_error; /* pointer to allocated memory for + SV* x_dl_last_error; /* pointer to allocated memory for last error message */ int x_dl_nonlazy; /* flag for immediate rather than lazy linking (spots unresolved symbol) */ @@ -31,7 +31,7 @@ typedef struct { START_MY_CXT -#define dl_last_error (MY_CXT.x_dl_last_error) +#define dl_last_error (SvPVX(MY_CXT.x_dl_last_error)) #define dl_nonlazy (MY_CXT.x_dl_nonlazy) #ifdef DL_LOADONCEONLY #define dl_loaded_files (MY_CXT.x_dl_loaded_files) @@ -85,7 +85,7 @@ dl_generic_private_init(pTHX) /* called by dl_*.xs dl_private_init() */ char *perl_dl_nonlazy; MY_CXT_INIT; - dl_last_error = NULL; + MY_CXT.x_dl_last_error = newSVpvn("", 0); dl_nonlazy = 0; #ifdef DL_LOADONCEONLY dl_loaded_files = Nullhv; @@ -129,14 +129,8 @@ SaveError(pTHX_ char* pat, ...) message = SvPV(msv,len); len++; /* include terminating null char */ - /* Allocate some memory for the error message */ - if (dl_last_error) - dl_last_error = (char*)saferealloc(dl_last_error, len); - else - dl_last_error = (char*)safemalloc(len); - /* Copy message into dl_last_error (including terminating null char) */ - strncpy(dl_last_error, message, len) ; + sv_setpvn(MY_CXT.x_dl_last_error, message, len) ; DLDEBUG(2,PerlIO_printf(Perl_debug_log, "DynaLoader: stored error msg '%s'\n",dl_last_error)); }