3
static sboolean _s_mm_initialized = FALSE;
4
static SMMType _s_mm_type = S_MM_TYPE_NONE;
7
s_mm_init (SMMType type) {
8
if (!_s_mm_initialized) {
9
_s_mm_initialized = TRUE;
13
_s_mm_type = S_MM_TYPE_LIBC;
19
s_mm_type_get_name (SMMType type) {
20
return SMMTypeName[type];
34
s_malloc (size_t size) {
36
if (_s_mm_type == S_MM_TYPE_GC) {
37
return GC_MALLOC (size);
44
s_free (spointer pointer) {
46
if (_s_mm_type == S_MM_TYPE_GC) {
47
/* Because libgc handles the freeing of these things, we just set it to
48
* NULL and be done with it.
50
* This also means that we can used this as a normal free and not have to
51
* deal with setting it to NULL.
61
s_realloc (spointer pointer, size_t size) {
63
if (_s_mm_type == S_MM_TYPE_GC) {
64
return GC_REALLOC (pointer, size);
67
return realloc (pointer, size);
71
s_calloc (size_t num, size_t size) {
73
if (_s_mm_type == S_MM_TYPE_GC) {
74
/* This should work. */
75
spointer ret_val = GC_MALLOC (num * size);
79
return calloc (num, size);