2 * Copyright © 2001 Novell, Inc. All Rights Reserved.
4 * You may distribute under the terms of either the GNU General Public
5 * License or the Artistic License, as specified in the README file.
10 * FILENAME : nwperlsys.c
11 * DESCRIPTION : Contains calls to Perl APIs and
12 * utility functions calls
15 * Date Created : June 12th 2001.
16 * Date Modified: June 26th 2001.
24 //Including this is giving premature end-of-file error during compilation
27 #ifdef PERL_IMPLICIT_SYS
29 //Includes iperlsys.h and function definitions
30 #include "nwperlsys.h"
32 /*============================================================================================
34 Function : fnFreeMemEntry
36 Description : Called for each outstanding memory allocation at the end of a script run.
37 Frees the outstanding allocations
39 Parameters : ptr (IN).
44 ==============================================================================================*/
46 void fnFreeMemEntry(void* ptr, void* context)
50 PerlMemFree(NULL, ptr);
53 /*============================================================================================
55 Function : fnAllocListHash
57 Description : Hashing function for hash table of memory allocations.
59 Parameters : invalue (IN).
63 ==============================================================================================*/
65 unsigned fnAllocListHash(void* const& invalue)
67 return (((unsigned) invalue & 0x0000ff00) >> 8);
70 /*============================================================================================
74 Description : creates a Perl interpreter variable and initializes
78 Returns : Pointer to Perl interpreter
80 ==============================================================================================*/
82 EXTERN_C PerlInterpreter*
85 PerlInterpreter* my_perl = NULL;
87 WCValHashTable<void*>* m_allocList;
88 m_allocList = new WCValHashTable<void*> (fnAllocListHash, 256);
89 fnInsertHashListAddrs(m_allocList, FALSE);
91 my_perl = perl_alloc_using(&perlMem,
101 //nw5_internal_host = m_allocList;
106 /*============================================================================================
108 Function : perl_alloc_override
110 Description : creates a Perl interpreter variable and initializes
112 Parameters : Pointer to structure containing function pointers
114 Returns : Pointer to Perl interpreter
116 ==============================================================================================*/
117 EXTERN_C PerlInterpreter*
118 perl_alloc_override(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
119 struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv,
120 struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO,
121 struct IPerlDir** ppDir, struct IPerlSock** ppSock,
122 struct IPerlProc** ppProc)
124 PerlInterpreter *my_perl = NULL;
126 struct IPerlMem* lpMem;
127 struct IPerlEnv* lpEnv;
128 struct IPerlStdIO* lpStdio;
129 struct IPerlLIO* lpLIO;
130 struct IPerlDir* lpDir;
131 struct IPerlSock* lpSock;
132 struct IPerlProc* lpProc;
134 WCValHashTable<void*>* m_allocList;
135 m_allocList = new WCValHashTable<void*> (fnAllocListHash, 256);
136 fnInsertHashListAddrs(m_allocList, FALSE);
173 my_perl = perl_alloc_using(lpMem,
184 //nw5_internal_host = pHost;
188 /*============================================================================================
190 Function : nw5_delete_internal_host
192 Description : Deletes the alloc_list pointer
194 Parameters : alloc_list pointer
198 ==============================================================================================*/
201 nw5_delete_internal_host(void *h)
203 WCValHashTable<void*>* m_allocList;
205 BOOL m_dontTouchHashLists;
206 if (fnGetHashListAddrs(&listptr,&m_dontTouchHashLists)) {
207 m_allocList = (WCValHashTable<void*>*)listptr;
208 fnInsertHashListAddrs(m_allocList, TRUE);
211 m_allocList->forAll(fnFreeMemEntry, NULL);
212 fnInsertHashListAddrs(NULL, FALSE);
218 #endif /* PERL_IMPLICIT_SYS */