source: trunk/essentials/dev-lang/perl/NetWare/nwvmem.h@ 3187

Last change on this file since 3187 was 3181, checked in by bird, 19 years ago

perl 5.8.8

File size: 6.7 KB
Line 
1
2/*
3 * Copyright © 2001 Novell, Inc. All Rights Reserved.
4 *
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
7 *
8 */
9
10/*
11 * FILENAME : NWVMem.h
12 * DESCRIPTION : Memory management for Perl Interpreter on NetWare.
13 * Watcom's hash table is used to store memory pointers.
14 * All malloc's, realloc's, free's go through this.
15 * Author : HYAK, SGP
16 * Date : Januray 2001.
17 *
18 */
19
20
21
22#ifndef ___NWVMEM_H_INC___
23#define ___NWVMEM_H_INC___
24
25
26#include "win32ish.h" // For "BOOL", "TRUE" and "FALSE"
27#include <nwhashcls.h> // CW changes
28#include <nwmalloc.h>
29#include "string.h"
30
31
32
33class VMem
34{
35public:
36 VMem();
37 virtual ~VMem();
38 virtual void* Malloc(size_t size);
39 virtual void* Realloc(void* pMem, size_t size);
40 virtual void Free(void* pMem);
41 virtual void* Calloc(size_t num, size_t size);
42
43protected:
44 BOOL m_dontTouchHashLists;
45// WCValHashTable<void*>* m_allocList;
46 NWPerlHashList *m_allocList; // CW changes
47};
48
49
50
51
52/*============================================================================================
53
54 Function : fnAllocListHash
55
56 Description : Hashing function for hash table of memory allocations.
57
58 Parameters : invalue (IN).
59
60 Returns : unsigned.
61
62==============================================================================================*/
63
64unsigned fnAllocListHash(void* const& invalue)
65{
66 return (((unsigned) invalue & 0x0000ff00) >> 8);
67}
68
69
70
71/*============================================================================================
72
73 Function : fnFreeMemEntry
74
75 Description : Called for each outstanding memory allocation at the end of a script run.
76 Frees the outstanding allocations
77
78 Parameters : ptr (IN).
79 context (IN)
80
81 Returns : Nothing.
82
83==============================================================================================*/
84
85void fnFreeMemEntry(void* ptr, void* context)
86{
87 VMem* pVMem = (VMem*) context;
88
89 if(ptr && pVMem)
90 {
91 pVMem->Free(ptr);
92 ptr=NULL;
93 pVMem = NULL;
94 context = NULL;
95 }
96}
97
98
99
100/*============================================================================================
101
102 Function : VMem Constructor
103
104 Description :
105