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.
28 //Including this is giving premature end-of-file error during compilation
31 #ifdef PERL_IMPLICIT_SYS
33 //Includes iperlsys.h and function definitions
34 #include "nwperlsys.h"
36 /*============================================================================================
38 Function : fnFreeMemEntry
40 Description : Called for each outstanding memory allocation at the end of a script run.
41 Frees the outstanding allocations
43 Parameters : ptr (IN).
48 ==============================================================================================*/
50 void fnFreeMemEntry(void* ptr, void* context)
54 PerlMemFree(NULL, ptr);
57 /*============================================================================================
59 Function : fnAllocListHash
61 Description : Hashing function for hash table of memory allocations.
63 Parameters : invalue (IN).
67 ==============================================================================================*/
69 unsigned fnAllocListHash(void* const& invalue)
71 return (((unsigned) invalue & 0x0000ff00) >> 8);
74 /*============================================================================================
78 Description : creates a Perl interpreter variable and initializes
82 Returns : Pointer to Perl interpreter
84 ==============================================================================================*/
86 EXTERN_C PerlInterpreter*
89 PerlInterpreter* my_perl = NULL;
91 WCValHashTable<void*>* m_allocList;
92 m_allocList = new WCValHashTable<void*> (fnAllocListHash, 256);
93 fnInsertHashListAddrs(m_allocList, FALSE);
95 my_perl = perl_alloc_using(&perlMem,
106 CPerlObj* pPerl = (CPerlObj*)my_perl;
108 //nw5_internal_host = m_allocList;
113 /*============================================================================================
115 Function : perl_alloc_override
117 Description : creates a Perl interpreter variable and initializes
119 Parameters : Pointer to structure containing function pointers
121 Returns : Pointer to Perl interpreter
123 ==============================================================================================*/
124 EXTERN_C PerlInterpreter*
125 perl_alloc_override(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
126 struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv,
127 struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO,
128 struct IPerlDir** ppDir, struct IPerlSock** ppSock,
129 struct IPerlProc** ppProc)
131 PerlInterpreter *my_perl = NULL;
133 struct IPerlMem* lpMem;
134 struct IPerlEnv* lpEnv;
135 struct IPerlStdIO* lpStdio;
136 struct IPerlLIO* lpLIO;
137 struct IPerlDir* lpDir;
138 struct IPerlSock* lpSock;
139 struct IPerlProc* lpProc;
141 WCValHashTable<void*>* m_allocList;
142 m_allocList = new WCValHashTable<void*> (fnAllocListHash, 256);
143 fnInsertHashListAddrs(m_allocList, FALSE);
180 my_perl = perl_alloc_using(lpMem,
192 CPerlObj* pPerl = (CPerlObj*)my_perl;
194 //nw5_internal_host = pHost;
198 /*============================================================================================
200 Function : nw5_delete_internal_host
202 Description : Deletes the alloc_list pointer
204 Parameters : alloc_list pointer
208 ==============================================================================================*/
211 nw5_delete_internal_host(void *h)
213 WCValHashTable<void*>* m_allocList;
215 BOOL m_dontTouchHashLists;
216 if (fnGetHashListAddrs(&listptr,&m_dontTouchHashLists)) {
217 m_allocList = (WCValHashTable<void*>*)listptr;
218 fnInsertHashListAddrs(m_allocList, TRUE);
221 m_allocList->forAll(fnFreeMemEntry, NULL);
222 fnInsertHashListAddrs(NULL, FALSE);
228 #endif /* PERL_IMPLICIT_SYS */