MEMFLAG.H 4.4 KB

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