|
1 /* |
|
2 * Copyright (c) 1999 - 2001 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 /*************************************************************************** |
|
20 ** File: nwx_mem.h |
|
21 ** Purpose: Provides the interface to memory management |
|
22 **************************************************************************/ |
|
23 #ifndef NWX_MEM_H |
|
24 #define NWX_MEM_H |
|
25 |
|
26 #ifdef __cplusplus |
|
27 extern "C" { |
|
28 #endif |
|
29 |
|
30 /* |
|
31 ** Includes |
|
32 */ |
|
33 #include "nwx_defs.h" |
|
34 |
|
35 /***************************************************************** |
|
36 ** Subsystem Name: Memory |
|
37 ** Description: Provides allocation and free routines for memory |
|
38 ******************************************************************/ |
|
39 |
|
40 /* |
|
41 ** Global Function Declarations |
|
42 */ |
|
43 |
|
44 /* Uncomment for memory profiling. |
|
45 This ALSO needs to be defined in rb_wae\bld\utils\include\nwx_mem.h |
|
46 so that the rbinterpreter_memprofu.def file will be used. |
|
47 */ |
|
48 |
|
49 /* |
|
50 #ifdef _DEBUG |
|
51 #define FEATURE_MEMORY_PROFILE 1 |
|
52 #endif |
|
53 */ |
|
54 |
|
55 #ifdef FEATURE_MEMORY_PROFILE |
|
56 |
|
57 #define NW_Mem_Malloc(x) NW_Mem_Malloc_Pro(x,__FILE__,__LINE__) |
|
58 #define NW_Mem_Free(x) NW_Mem_Free_Pro(x,__FILE__,__LINE__) |
|
59 #define NW_Mem_Malloc_Address &NW_Mem_Malloc_Pro |
|
60 #define NW_Mem_Free_Address &NW_Mem_Free_Pro |
|
61 |
|
62 void SendStringToLogger2(char *strFormat, NW_Ucs2 *strValue); |
|
63 void SendStringToLogger1(char *strMsg); |
|
64 void *NW_Mem_Malloc_Pro(NW_Uint32 nbytes, char * file, NW_Uint32 line); |
|
65 void NW_Mem_Free_Pro(void *buffer, char * file, NW_Uint32 line); |
|
66 |
|
67 #else |
|
68 |
|
69 #define NW_Mem_Malloc(x) NW_Mem_Malloc_No_Pro(x) |
|
70 #define NW_Mem_Free(x) NW_Mem_Free_No_Pro(x) |
|
71 #define NW_Mem_Malloc_Address &NW_Mem_Malloc_No_Pro |
|
72 #define NW_Mem_Free_Address &NW_Mem_Free_No_Pro |
|
73 |
|
74 void *NW_Mem_Malloc_No_Pro(NW_Uint32 memorySize); |
|
75 void NW_Mem_Free_No_Pro(void *mem); |
|
76 |
|
77 #endif /* FEATURE_MEMORY_PROFILE */ |
|
78 |
|
79 void *NW_Mem_memset(void *s, NW_Uint32 c, NW_Uint32 n); |
|
80 void *NW_Mem_memcpy(void *s1, const void *s2, NW_Uint32 n); |
|
81 void *NW_Mem_memmove(void *s1, const void *s2, NW_Uint32 n); |
|
82 NW_Int32 NW_Mem_memcmp(const void *s1, const void *s2, NW_Uint32 n); |
|
83 |
|
84 #ifdef _DEBUG |
|
85 |
|
86 #define NW_MEM_OOMMODE_NEVER 0 |
|
87 #define NW_MEM_OOMMODE_AFTER 1 |
|
88 #define NW_MEM_OOMMODE_RANDOM 2 |
|
89 |
|
90 NW_Uint32 NW_Mem_GetMemInUse(); |
|
91 NW_Uint32 NW_Mem_GetHighWaterMark(); |
|
92 void NW_Mem_ResetHighWaterMark(); |
|
93 NW_Bool NW_Mem_IsHeapConstrained(); |
|
94 void NW_Mem_ConstrainHeap(NW_Bool constrain); |
|
95 NW_Uint32 NW_Mem_GetHeapSize(); |
|
96 void NW_Mem_SetHeapSize(NW_Uint32 size); |
|
97 NW_Uint8 NW_Mem_GetOOMMode(); |
|
98 void NW_Mem_SetOOMMode(NW_Uint8 mode); |
|
99 NW_Uint32 NW_Mem_GetMaxAllocs(); |
|
100 void NW_Mem_SetMaxAllocs(NW_Uint32 allocs); |
|
101 |
|
102 #endif |
|
103 |
|
104 #ifdef __cplusplus |
|
105 } /* extern "C" */ |
|
106 #endif |
|
107 |
|
108 #endif /* NWX_MEM_H */ |
|
109 |
|
110 |