30 #include "engines/icb/p4.h" 31 #include "engines/icb/common/px_array.h" 32 #include "engines/icb/common/px_string.h" 33 #include "engines/icb/common/px_common.h" 34 #include "engines/icb/common/px_clu_api.h" 47 inline int32 SameUrl(
const char *urla,
const uint32 urla_hash,
const uint32 clustera_hash,
const char *urlb,
const uint32 urlb_hash,
const uint32 clusterb_hash);
51 #include "engines/icb/res_man_pc.h" 57 extern uint32 MAX_MEM_BLOCKS;
63 #define RM_LOADNOW 0 // load file right now 64 #define RM_ASYNCLOAD 1 // async load file 66 #define MAKE_TOTAL_HASH(c, f) (2 * c + f) 106 uint32 total_free_memory;
109 uint32 number_files_open;
110 uint32 max_mem_blocks;
115 int32 num_mem_offsets;
117 uint16 current_time_frame;
120 int32 amount_of_defrags;
124 res_man(uint8 *base, uint32 size);
125 void Construct(uint8 *base, uint32 size,
mem *memList,
mem_offset *memOffsets, uint32 nMemBlocks);
128 void AddMemOffset(uint32 total_hash, int32 search);
129 inline int32 FindMemSearch(uint32 total_hash);
130 inline int32 FindMemOffset(uint32 total_hash);
136 inline uint8 *Get_memory_base();
137 inline uint32 Get_memory_size();
139 void Set_auto_timeframe_advance();
140 void Set_to_no_defrag();
142 int16 find_oldest_file();
143 void Garbage_removal();
147 void Res_open_cluster(
const char *cluster_url, uint32 &cluster_hash, int32 size = -1);
149 void Res_open_mini_cluster(
const char *cluster_url, uint32 &cluster_hash,
const char *fake_cluster_url, uint32 &fake_cluster_hash);
153 uint8 *Res_open(
const char *url, uint32 &url_hash,
const char *cluster_url, uint32 &cluster_hash,
154 int32 compressed = 0,
155 int32 *ret_len = NULL);
159 uint8 *Res_alloc(uint32 url_hash,
const char *cluster, uint32 cluster_hash, uint32 length);
161 void Res_purge(
const char *url, uint32 url_hash,
const char *cluster, uint32 cluster_hash, uint32 fatal = 1);
162 void Res_purge_all();
163 uint32 Fetch_size(
const char *url, uint32 url_hash,
const char *cluster_url, uint32 cluster_hash);
165 void Advance_time_stamp();
166 uint32 Check_file_size(
const char *url, uint32 url_hash,
const char *cluster_url, uint32 cluster_hash);
167 bool8 Test_file(
const char *url);
168 bool8 Test_file(
const char *url, uint32 url_hash,
const char *cluster_url, uint32 cluster_hash);
170 uint32 Fetch_files_open();
171 uint32 Fetch_total_pool_size();
172 uint32 Fetch_free_memory();
173 uint32 Fetch_mem_used();
174 mem *Fetch_mem_list();
175 uint32 Fetch_max_mem_blocks();
177 uint32 Fetch_old_memory(int32 number_of_cycles);
184 inline void Id(int32 newId);
188 inline void MakeHash(
const char *s, uint32 &h);
189 inline int32 CheckHash(
const char *s,
const uint32 h, uint32 &h2);
191 const char *OpenFile(int32 &cluster_search,
RMParams *params);
194 int16 OldFindFile(uint32 url_hash, uint32 cluster_hash, uint32 total_hash);
197 int16 FindFile(uint32 url_hash, uint32 cluster_hash, uint32 total_hash);
200 void FindFileCluster(int32 &url_search, int32 &cluster_search,
RMParams *params);
204 inline int32 SameFile(
mem *current_mem_block,
const char *url,
const uint32 url_hash,
const uint32 cluster_hash);
206 void ReadFile(
const char *new_url,
RMParams *params);
207 uint32 FindMemBlock(uint32 adj_len,
RMParams *params);
208 uint8 *AllocMemory(uint32 &memory_tot);
210 void Initialise(uint32 memory_tot);
212 uint8 *Internal_open(
RMParams *params, int32 *ret_len = NULL);
214 uint8 *LoadFile(int32 &cluster_search,
RMParams *params);
216 int16 Find_space(uint32 len);
217 uint16 Fetch_spawn(uint16 parent);
219 bool8 auto_time_advance;
227 inline int32 res_man::FindMemOffset(uint32 hash) {
232 if (!num_mem_offsets)
235 top = num_mem_offsets - 1;
240 current = mem_offset_list[i].total_hash;
243 else if (top == bottom)
245 else if (hash > current) {
247 i = (top + bottom) >> 1;
250 i = (top + bottom) >> 1;
255 inline int32 res_man::FindMemSearch(uint32 total_hash) {
256 int32 i = FindMemOffset(total_hash);
260 return mem_offset_list[i].search;
263 inline uint8 *res_man::Get_memory_base() {
267 inline uint32 res_man::Get_memory_size() {
271 inline void res_man::Set_auto_timeframe_advance() {
272 auto_time_advance = TRUE8;
275 inline void res_man::Set_to_no_defrag() {
279 inline uint32 res_man::Fetch_total_pool_size() {
283 inline uint32 res_man::Fetch_free_memory() {
284 return (total_free_memory);
287 inline uint32 res_man::Fetch_files_open() {
288 return (number_files_open);
291 inline mem *res_man::Fetch_mem_list() {
return mem_list; }
293 inline uint32 res_man::Fetch_max_mem_blocks() {
return max_mem_blocks; }
295 inline uint32 res_man::Fetch_mem_used() {
296 return (total_pool - total_free_memory);
299 inline int32 res_man::SameFile(
mem *current_mem_block,
const char *url,
const uint32 url_hash,
const uint32 cluster_hash) {
300 return SameUrl(url, url_hash, cluster_hash, NULL, current_mem_block->url_hash, current_mem_block->cluster_hash);
303 inline void res_man::MakeHash(
const char *s, uint32 &h) {
306 h = EngineHashString(s);
309 inline int32 res_man::CheckHash(
const char *s,
const uint32 h, uint32 &h2) {
312 h2 = EngineHashString(s);
319 inline void res_man::Id(int32 newId) {
id = (uint8)newId; }
321 inline int32 res_man::Id() {
return (int32)id; }
323 extern uint32 memory_available;
326 void Print_console_clusters();
330 #endif // #ifndef RES_MAN_H
Definition: algorithm.h:29
Definition: res_man.h:104
Definition: px_clu_api.h:76