CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

MEMFLAG.H (4481B)


      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 //#pragma option -Jgd
     73 
     74 inline void * operator new(size_t size, MemoryFlagType flag)
     75 {
     76 	return(Alloc(size, flag));
     77 }
     78 inline void * operator new[] (size_t size, MemoryFlagType flag)
     79 {
     80 	return(Alloc(size, flag));
     81 }
     82 
     83 //#pragma option -Jgd
     84 
     85 /*=========================================================================*/
     86 /* The following prototypes are for the file: MEM_COPY.ASM						*/
     87 /*=========================================================================*/
     88 
     89 extern "C" {
     90 	void __cdecl Mem_Copy(void const *source, void *dest, unsigned long bytes_to_copy);
     91 }
     92 
     93 
     94 inline void *Add_Long_To_Pointer(void const *ptr, long size)
     95 {
     96  	return ((void *) ( (char const *) ptr + size));
     97 }
     98 
     99 extern void (*Memory_Error)(void);
    100 extern void (*Memory_Error_Exit)(char *string);
    101 
    102 extern unsigned long MinRam;		// Record of least memory at worst case.
    103 extern unsigned long MaxRam;		// Record of total allocated at worst case.
    104 
    105 
    106 #endif