This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
tabs, not spaces, in MANIFEST. No, I can't remember why this is.
[perl5.git] / NetWare / interface.c
index 3525dcc..0788e3a 100644 (file)
@@ -8,23 +8,25 @@
  */
 
 /*
- * FILENAME            :       interface.c
- * DESCRIPTION :       Perl parsing and running functions.
- * Author              :       SGP
- * Date                        :       January 2001.
- *
+ * FILENAME     :   interface.c
+ * DESCRIPTION  :   Calling Perl APIs.
+ * Author       :   SGP
+ * Date        Created :   January 2001.
+ * Date Modified:   July 2nd 2001.
  */
 
 
 
 #include "interface.h"
-
+#include "nwtinfo.h"
 
 static void xs_init(pTHX);
 
 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 (pTHXo_ CV* cv);
+EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
+
+EXTERN_C BOOL Remove_Thread_Ctx(void);
 
 
 ClsPerlHost::ClsPerlHost()
@@ -42,6 +44,18 @@ ClsPerlHost::VersionNumber()
        return 0;
 }
 
+bool
+ClsPerlHost::RegisterWithThreadTable()
+{
+       return(fnRegisterWithThreadTable());
+}
+
+bool
+ClsPerlHost::UnregisterWithThreadTable()
+{
+       return(fnUnregisterWithThreadTable());
+}
+
 int
 ClsPerlHost::PerlCreate(PerlInterpreter *my_perl)
 {
@@ -68,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();
 }
 
 /*============================================================================================
@@ -129,23 +152,7 @@ int RunPerl(int argc, char **argv, char **env)
                if(exitstatus == 0)
                {
                        #if defined(TOP_CLONE) && defined(USE_ITHREADS)         // XXXXXX testing
-                               #  ifdef PERL_OBJECT
-                                       CPerlHost *h = new CPerlHost();
-                                       new_perl = perl_clone_using(my_perl, 1,
-                                                                               h->m_pHostperlMem,
-                                                                               h->m_pHostperlMemShared,
-                                                                               h->m_pHostperlMemParse,
-                                                                               h->m_pHostperlEnv,
-                                                                               h->m_pHostperlStdIO,
-                                                                               h->m_pHostperlLIO,
-                                                                               h->m_pHostperlDir,
-                                                                               h->m_pHostperlSock,
-                                                                               h->m_pHostperlProc
-                                                                               );
-                                       CPerlObj *pPerl = (CPerlObj*)new_perl;
-                               #  else
-                                       new_perl = perl_clone(my_perl, 1);
-                               #  endif
+                               new_perl = perl_clone(my_perl, 1);
 
                                exitstatus = perl_run(new_perl);        // Run Perl.
                                PERL_SET_THX(my_perl);
@@ -155,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
 
@@ -178,7 +188,7 @@ int RunPerl(int argc, char **argv, char **env)
 //
 IPerlHost* AllocStdPerl()
 {
-       return new ClsPerlHost();
+       return (IPerlHost*) new ClsPerlHost();
 }
 
 
@@ -190,7 +200,7 @@ IPerlHost* AllocStdPerl()
 //
 void FreeStdPerl(IPerlHost* pPerlHost)
 {
-       delete (ClsPerlHost*) pPerlHost;
+       if (pPerlHost)
+               delete (ClsPerlHost*) pPerlHost;
 }
 
-