mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-02 09:47:58 +03:00

- No more enums.h, constants.h, macro.h, etc... - moved all structure in types.h to there respective file.
43 lines
No EOL
671 B
C++
43 lines
No EOL
671 B
C++
#include "framework.h"
|
|
#include "malloc.h"
|
|
|
|
|
|
char* malloc_buffer;
|
|
int malloc_size;
|
|
char* malloc_ptr;
|
|
int malloc_free;
|
|
int malloc_used;
|
|
|
|
char* game_malloc(int size)
|
|
{
|
|
char* ptr;
|
|
|
|
size = (size + 3) & 0xfffffffc;
|
|
if (size <= malloc_free)
|
|
{
|
|
ptr = malloc_ptr;
|
|
malloc_free -= size;
|
|
malloc_used += size;
|
|
malloc_ptr += size;
|
|
return ptr;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
void init_game_malloc()
|
|
{
|
|
malloc_size = 1048576 * 128;
|
|
malloc_buffer = (char*)malloc(malloc_size);
|
|
malloc_ptr = malloc_buffer;
|
|
malloc_free = malloc_size;
|
|
malloc_used = 0;
|
|
}
|
|
|
|
void game_free(int size, int type)
|
|
{
|
|
size = (size + 3) & (~3);
|
|
malloc_ptr -= size;
|
|
malloc_free += size;
|
|
malloc_used -= size;
|
|
} |