X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=NetWare%2Finterface.c;h=0788e3aab89e9205e19990e626c69b302b65e91c;hb=eb0f98c9231fa500029e4f3531ee246d1650a240;hp=43cf81a46485869dc94838048e4c64d07a86df00;hpb=acfe0abcedaf592fb4b9cb69ce3468308ae99d91;p=p5sagit%2Fp5-mst-13.2.git diff --git a/NetWare/interface.c b/NetWare/interface.c index 43cf81a..0788e3a 100644 --- a/NetWare/interface.c +++ b/NetWare/interface.c @@ -26,6 +26,8 @@ EXTERN_C int RunPerl(int argc, char **argv, char **env); EXTERN_C void Perl_nw5_init(int *argcp, char ***argvp); EXTERN_C void boot_DynaLoader (pTHX_ CV* cv); +EXTERN_C BOOL Remove_Thread_Ctx(void); + ClsPerlHost::ClsPerlHost() { @@ -80,8 +82,17 @@ void ClsPerlHost::PerlDestroy(PerlInterpreter *my_perl) { perl_destruct(my_perl); // Destructor for Perl. +} + +void +ClsPerlHost::PerlFree(PerlInterpreter *my_perl) +{ perl_free(my_perl); // Free the memory allocated for Perl. + // Remove the thread context set during Perl_set_context + // This is added here since for web script there is no other place this gets executed + // and it cannot be included into cgi2perl.xs unless this symbol is exported. + Remove_Thread_Ctx(); } /*============================================================================================ @@ -151,12 +162,15 @@ int RunPerl(int argc, char **argv, char **env) } nlm.PerlDestroy(my_perl); } + if(my_perl) + nlm.PerlFree(my_perl); #ifdef USE_ITHREADS if (new_perl) { PERL_SET_THX(new_perl); nlm.PerlDestroy(new_perl); + nlm.PerlFree(my_perl); } #endif @@ -174,7 +188,7 @@ int RunPerl(int argc, char **argv, char **env) // IPerlHost* AllocStdPerl() { - return new ClsPerlHost(); + return (IPerlHost*) new ClsPerlHost(); } @@ -186,7 +200,7 @@ IPerlHost* AllocStdPerl() // void FreeStdPerl(IPerlHost* pPerlHost) { - delete (ClsPerlHost*) pPerlHost; + if (pPerlHost) + delete (ClsPerlHost*) pPerlHost; } -