@@ -4,10 +4,10 @@ module c
4
4
// that Boehm will later know how to process. The callbacks here provide such versions:
5
5
fn cb_malloc_func (size usize) voidptr {
6
6
mut res := unsafe { nil }
7
- $if sdl_memory_no_gc ? {
8
- res = unsafe { C.malloc (size) }
9
- } $else {
7
+ $if sdl_use_gc ? {
10
8
res = unsafe { malloc (int (size)) }
9
+ } $else {
10
+ res = unsafe { C.malloc (size) }
11
11
}
12
12
$if trace_sdl_memory ? {
13
13
C.fprintf (C.stderr, c '>> sdl.c.cb_malloc_func | size: %lu | => %p \n ' , size, res)
@@ -17,10 +17,10 @@ fn cb_malloc_func(size usize) voidptr {
17
17
18
18
fn cb_calloc_func (nmemb usize, size usize) voidptr {
19
19
mut res := unsafe { nil }
20
- $if sdl_memory_no_gc ? {
21
- res = unsafe { C.calloc (int (nmemb), int (size)) }
22
- } $else {
20
+ $if sdl_use_gc ? {
23
21
res = unsafe { vcalloc (isize (nmemb) * isize (size)) }
22
+ } $else {
23
+ res = unsafe { C.calloc (int (nmemb), int (size)) }
24
24
}
25
25
$if trace_sdl_memory ? {
26
26
C.fprintf (C.stderr, c '>> sdl.c.cb_calloc_func | nmemb: %lu | size: %lu | => %p \n ' ,
@@ -31,10 +31,10 @@ fn cb_calloc_func(nmemb usize, size usize) voidptr {
31
31
32
32
fn cb_realloc_func (mem voidptr , size usize) voidptr {
33
33
mut res := unsafe { nil }
34
- $if sdl_memory_no_gc ? {
35
- res = unsafe { C.realloc (& u8 (mem), int (size)) }
36
- } $else {
34
+ $if sdl_use_gc ? {
37
35
res = unsafe { v_realloc (& u8 (mem), isize (size)) }
36
+ } $else {
37
+ res = unsafe { C.realloc (& u8 (mem), int (size)) }
38
38
}
39
39
$if trace_sdl_memory ? {
40
40
C.fprintf (C.stderr, c '>> sdl.c.cb_realloc_func | mem: %p | size: %lu | => %p \n ' ,
@@ -47,10 +47,10 @@ fn cb_free_func(mem voidptr) {
47
47
$if trace_sdl_memory ? {
48
48
C.fprintf (C.stderr, c '>> sdl.c.cb_free_func | mem: %p \n ' , mem)
49
49
}
50
- $if sdl_memory_no_gc ? {
51
- unsafe { C.free (mem) }
52
- } $else {
50
+ $if sdl_use_gc ? {
53
51
unsafe { free (mem) }
52
+ } $else {
53
+ unsafe { C.free (mem) }
54
54
}
55
55
}
56
56
0 commit comments