ScummVM API documentation
mem.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef MADS_CORE_MEM_H
23#define MADS_CORE_MEM_H
24
25#include "mads/core/general.h"
26
27namespace MADS {
28
29#define MEM_NONE 0xff /* Undefined (himem) */
30
31#define MEM_CONV 0 /* Conventional Memory */
32#define MEM_UMB 1 /* Upper memory block */
33#define MEM_HMA 2 /* High memory area */
34#define MEM_EMS 3 /* Expanded memory */
35#define MEM_XMS 4 /* Extended memory */
36
37
38extern byte mem_max_free_set;
39extern byte umb_max_free_set;
40
41extern byte mem_last_alloc_failed; /* True if last mem_get() failed */
42extern int mem_last_alloc_loader; /* Last loader to use mem_get() */
43extern long mem_last_alloc_size; /* Last size attempted by mem_get */
44extern long mem_last_alloc_avail; /* Last available memory */
45extern long mem_max_free; /* Most memory that was ever free */
46extern long mem_min_free; /* Least memory that was ever free */
47extern long umb_max_free; /* Most UMB that was ever free */
48extern long umb_min_free; /* Least UMB that was ever free */
49
50extern void (*mem_manager_update)(); /* Called at memory updates */
51extern int mem_manager_active; /* Flag if memory manager active */
52
53inline void *mem_normalize(void *in) {
54 return in;
55}
56inline void *mem_check_overflow(void *in) {
57 return in;
58}
59
60
61extern void *mem_get(long size);
62
66extern void *mem_get_name(long size, const char * /*block_name */= nullptr);
67
72extern bool mem_free(void *block);
73
77extern int mem_adjust_impl(void *&target, long size);
78
79template <typename T>
80inline int mem_adjust(T *&target, long size) {
81 return mem_adjust_impl(reinterpret_cast<void *&>(target), size);
82}
83
84extern void mem_save_free();
85extern void mem_restore_free();
86
87extern long mem_get_avail();
88extern long mem_conv_get_avail();
89extern void mem_set_video_mode(int mode);
90
91} // namespace MADS
92
93#endif