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 WCValHashTable<void*>* m_allocList;
134 m_allocList = new WCValHashTable<void*> (fnAllocListHash, 256);
135 fnInsertHashListAddrs(m_allocList, FALSE);
152 my_perl = perl_alloc_using(ppMem,
163 CPerlObj* pPerl = (CPerlObj*)my_perl;
165 //nw5_internal_host = pHost;
169 /*============================================================================================
171 Function : nw5_delete_internal_host
173 Description : Deletes the alloc_list pointer
175 Parameters : alloc_list pointer
179 ==============================================================================================*/
182 nw5_delete_internal_host(void *h)
184 WCValHashTable<void*>* m_allocList;
186 BOOL m_dontTouchHashLists;
187 if (fnGetHashListAddrs(&listptr,&m_dontTouchHashLists)) {
188 m_allocList = (WCValHashTable<void*>*)listptr;
189 fnInsertHashListAddrs(m_allocList, TRUE);
192 m_allocList->forAll(fnFreeMemEntry, NULL);
193 fnInsertHashListAddrs(NULL, FALSE);
199 #endif /* PERL_IMPLICIT_SYS */