MEMFLAG.H (4493B)
1 // 2 // Copyright 2020 Electronic Arts Inc. 3 // 4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 5 // software: you can redistribute it and/or modify it under the terms of 6 // the GNU General Public License as published by the Free Software Foundation, 7 // either version 3 of the License, or (at your option) any later version. 8 9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 10 // in the hope that it will be useful, but with permitted additional restrictions 11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 12 // distributed with this program. You should have received a copy of the 13 // GNU General Public License along with permitted additional restrictions 14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection 15 16 /*************************************************************************** 17 ** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ** 18 *************************************************************************** 19 * * 20 * Project Name : Memory System * 21 * * 22 * File Name : MEMFLAG.H * 23 * * 24 * Programmer : Jeff Wilson * 25 * * 26 * Start Date : April 4, 1994 * 27 * * 28 * Last Update : September 8, 1994 [IML] * 29 * * 30 *-------------------------------------------------------------------------* 31 * Functions: * 32 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 33 #ifndef MEMFLAG_H 34 #define MEMFLAG_H 35 // Memory Flags 36 /* 37 ** Memory allocation flags. These are the flags that are passed into Alloc 38 ** in order to control the type of memory allocated. 39 */ 40 typedef enum { 41 MEM_NORMAL = 0x0000, // Default memory (normal). 42 MEM_NEW = 0x0001, // Called by the operator new and was overloaded. 43 MEM_CLEAR = 0x0002, // Clear memory before returning. 44 MEM_REAL = 0x0004, // Clear memory before returning. 45 MEM_TEMP = 0x0008, // Clear memory before returning. 46 MEM_LOCK = 0x0010, // Lock the memory that we allocated 47 } MemoryFlagType; 48 49 50 /* 51 ** Prototypes for VMPAGEIN.ASM 52 */ 53 extern "C"{ 54 void __cdecl Force_VM_Page_In (void *buffer, int length); 55 } 56 57 /*=========================================================================*/ 58 /* The following prototypes are for the file: ALLOC.CPP */ 59 /*=========================================================================*/ 60 61 void * operator new(size_t size, MemoryFlagType flag); 62 void * operator new[] (size_t size, MemoryFlagType flag); 63 void *Alloc(unsigned long bytes_to_alloc, MemoryFlagType flags); 64 void Free(void const *pointer); 65 void DPMI_Lock(VOID const *ptr, long const size); 66 void DPMI_Unlock(void const *ptr, long const size); 67 void *Resize_Alloc(void *original_ptr, unsigned long new_size_in_bytes); 68 long Ram_Free(MemoryFlagType flag); 69 long Heap_Size(MemoryFlagType flag); 70 long Total_Ram_Free(MemoryFlagType flag); 71 72 //PG_TO_FIX 73 //#pragma option -Jgd 74 75 inline void * operator new(size_t size, MemoryFlagType flag) 76 { 77 return(Alloc(size, flag)); 78 } 79 inline void * operator new[] (size_t size, MemoryFlagType flag) 80 { 81 return(Alloc(size, flag)); 82 } 83 84 //#pragma option -Jgd 85 86 /*=========================================================================*/ 87 /* The following prototypes are for the file: MEM_COPY.ASM */ 88 /*=========================================================================*/ 89 90 extern "C" { 91 void __cdecl Mem_Copy(void const *source, void *dest, unsigned long bytes_to_copy); 92 } 93 94 95 inline void *Add_Long_To_Pointer(void const *ptr, long size) 96 { 97 return ((void *) ( (char const *) ptr + size)); 98 } 99 100 extern void (*Memory_Error)(void); 101 extern void (*Memory_Error_Exit)(char *string); 102 103 extern unsigned long MinRam; // Record of least memory at worst case. 104 extern unsigned long MaxRam; // Record of total allocated at worst case. 105 106 107 #endif