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);
90 my_perl = perl_alloc_using(&perlMem,
100 //nw5_internal_host = m_allocList;
105 /*============================================================================================
107 Function : perl_alloc_override
109 Description : creates a Perl interpreter variable and initializes
111 Parameters : Pointer to structure containing function pointers
113 Returns : Pointer to Perl interpreter
115 ==============================================================================================*/
116 EXTERN_C PerlInterpreter*
117 perl_alloc_override(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
118 struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv,
119 struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO,
120 struct IPerlDir** ppDir, struct IPerlSock** ppSock,
121 struct IPerlProc** ppProc)
123 PerlInterpreter *my_perl = NULL;
125 struct IPerlMem* lpMem;
126 struct IPerlEnv* lpEnv;
127 struct IPerlStdIO* lpStdio;
128 struct IPerlLIO* lpLIO;
129 struct IPerlDir* lpDir;
130 struct IPerlSock* lpSock;
131 struct IPerlProc* lpProc;
133 WCValHashTable<void*>* m_allocList;
134 m_allocList = new WCValHashTable<void*> (fnAllocListHash, 256);
135 fnInsertHashListAddrs(m_allocList, FALSE);
171 my_perl = perl_alloc_using(lpMem,
182 //nw5_internal_host = pHost;
186 /*============================================================================================
188 Function : nw5_delete_internal_host
190 Description : Deletes the alloc_list pointer
192 Parameters : alloc_list pointer
196 ==============================================================================================*/
199 nw5_delete_internal_host(void *h)
201 WCValHashTable<void*>* m_allocList;
203 BOOL m_dontTouchHashLists;
204 if (fnGetHashListAddrs(&listptr,&m_dontTouchHashLists)) {
205 m_allocList = (WCValHashTable<void*>*)listptr;
206 fnInsertHashListAddrs(m_allocList, TRUE);
209 m_allocList->forAll(fnFreeMemEntry, NULL);
210 fnInsertHashListAddrs(NULL, FALSE);
216 #endif /* PERL_IMPLICIT_SYS */