1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

all: wrap up unsafe { nil } (p. 3)

This commit is contained in:
Alexander Medvednikov 2022-07-21 21:01:30 +03:00
parent a68d03ac59
commit 9099594a49
51 changed files with 86 additions and 86 deletions

View File

@ -72,7 +72,7 @@ fn (mut a array) ensure_cap_noscan(required int) {
}
new_size := u64(cap) * u64(a.element_size)
new_data := vcalloc_noscan(new_size)
if a.data != voidptr(0) {
if a.data != unsafe { nil } {
unsafe { vmemcpy(new_data, a.data, u64(a.len) * u64(a.element_size)) }
// TODO: the old data may be leaked when no GC is used (ref-counting?)
}

View File

@ -653,4 +653,4 @@ pub fn print_backtrace() {
__global g_main_argc = int(0)
[markused]
__global g_main_argv = voidptr(0)
__global g_main_argv = unsafe { nil }

View File

@ -267,7 +267,7 @@ fn break_if_debugger_attached() {
$if tinyc {
unsafe {
mut ptr := &voidptr(0)
*ptr = voidptr(0)
*ptr = nil
_ = ptr
}
} $else {

View File

@ -4,7 +4,7 @@ fn test_isnil_byteptr() {
}
fn test_isnil_voidptr() {
pv := voidptr(0)
pv := unsafe { nil }
assert isnil(pv)
}

View File

@ -20,7 +20,7 @@ fn (mut m map) internal_set(key JS.Any, val JS.Any) {
}
fn (mut m map) internal_get(key JS.Any) JS.Any {
mut val := JS.Any(voidptr(0))
mut val := JS.Any(unsafe { nil })
//$if es5 {
#if (typeof key != "string" && '$toJS' in key) key = key.$toJS();
#val = m.val.map[key]

View File

@ -43,11 +43,11 @@ fn system_alloc(_ voidptr, size usize) (voidptr, usize, u32) {
if e == .enoerror {
return a, size, 0
}
return voidptr(0), 0, 0
return unsafe { nil }, 0, 0
}
fn system_remap(_ voidptr, ptr voidptr, oldsize usize, newsize usize, can_move bool) voidptr {
return voidptr(0)
return unsafe { nil }
}
fn system_free_part(_ voidptr, ptr voidptr, oldsize usize, newsize usize) bool {
@ -87,6 +87,6 @@ fn get_linux_allocator() dlmalloc.Allocator {
can_release_part: system_can_release_part
allocates_zeros: system_allocates_zeros
page_size: system_page_size
data: voidptr(0)
data: unsafe { nil }
}
}

View File

@ -488,7 +488,7 @@ fn (mut m map) get_and_set(key voidptr, zero voidptr) voidptr {
// Key not found, insert key with zero-value
m.set(key, zero)
}
return voidptr(0)
return unsafe { nil }
}
// If `key` matches the key of an element in the container,

View File

@ -210,8 +210,8 @@ fn test_various_map_value() {
// m13['test'] = rune(0)
// assert m13['test'] == rune(0)
mut m14 := map[string]voidptr{}
m14['test'] = voidptr(0)
assert m14['test'] == voidptr(0)
m14['test'] = unsafe { nil }
assert m14['test'] == unsafe { nil }
mut m15 := map[string]&u8{}
m15['test'] = &u8(0)
assert m15['test'] == &u8(0)

View File

@ -65,7 +65,7 @@ fn vmemory_block_malloc(n isize) &byte {
[unsafe]
fn prealloc_vinit() {
unsafe {
g_memory_block = vmemory_block_new(voidptr(0), prealloc_block_size)
g_memory_block = vmemory_block_new(nil, prealloc_block_size)
$if !freestanding {
C.atexit(prealloc_vcleanup)
}

View File

@ -148,7 +148,7 @@ fn bare_backtrace() string {
fn __exit(code int) {
unsafe {
// the only way to abort process execution in WASM
mut x := &int(voidptr(0))
mut x := &int(nil)
*x = code
}
for {}

View File

@ -14,7 +14,7 @@ mut:
struct Transition {
mut:
to string
condition_handler ConditionFn = voidptr(0)
condition_handler ConditionFn = unsafe { nil }
}
pub struct StateMachine {

View File

@ -87,14 +87,14 @@ pub fn (mut list LinkedList<T>) pop() ?T {
if unsafe { node.next == 0 } {
// first node case
// set to null
list.head = voidptr(0)
list.head = unsafe { nil }
} else {
for unsafe { node.next.next != 0 } {
node = node.next
}
to_return = node.next.data
// set to null
node.next = voidptr(0)
node.next = unsafe { nil }
}
list.len -= 1
return to_return

View File

@ -55,22 +55,22 @@ fn system_alloc(_ voidptr, size usize) (voidptr, usize, u32) {
unsafe {
mem_prot := MemProt(int(MemProt.prot_read) | int(MemProt.prot_write))
map_flags := MapFlags(int(MapFlags.map_private) | int(MapFlags.map_anonymous))
addr := C.mmap(voidptr(0), size, int(mem_prot), int(map_flags), -1, 0)
addr := C.mmap(nil, size, int(mem_prot), int(map_flags), -1, 0)
if addr == voidptr(-1) {
return voidptr(0), 0, 0
return nil, 0, 0
} else {
return addr, size, 0
}
}
} $else {
return voidptr(0), 0, 0
return unsafe { nil }, 0, 0
}
return voidptr(0), 0, 0
return unsafe { nil }, 0, 0
}
fn system_remap(_ voidptr, ptr voidptr, oldsize usize, newsize usize, can_move bool) voidptr {
return voidptr(0)
return unsafe { nil }
}
fn system_free_part(_ voidptr, ptr voidptr, oldsize usize, newsize usize) bool {
@ -121,6 +121,6 @@ pub fn get_system_allocator() Allocator {
can_release_part: system_can_release_part
allocates_zeros: system_allocates_zeros
page_size: system_page_size
data: voidptr(0)
data: unsafe { nil }
}
}

View File

@ -1,11 +1,11 @@
module dlmalloc
fn system_alloc(_ voidptr, size usize) (voidptr, usize, u32) {
return voidptr(0), 0, 0
return unsafe { nil }, 0, 0
}
fn system_remap(_ voidptr, ptr voidptr, oldsize usize, newsize usize, can_move bool) voidptr {
return voidptr(0)
return unsafe { nil }
}
fn system_free_part(_ voidptr, ptr voidptr, oldsize usize, newsize usize) bool {
@ -37,6 +37,6 @@ pub fn get_system_allocator() Allocator {
can_release_part: system_can_release_part
allocates_zeros: system_allocates_zeros
page_size: system_page_size
data: voidptr(0)
data: unsafe { nil }
}
}

View File

@ -20,7 +20,7 @@ mut:
struct EventHandler {
name string
handler EventHandlerFn
receiver voidptr = voidptr(0)
receiver voidptr = unsafe { nil }
once bool
}

View File

@ -10,7 +10,7 @@ pub struct DrawImageConfig {
pub:
flip_x bool
flip_y bool
img &Image = voidptr(0)
img &Image = unsafe { nil }
img_id int
img_rect Rect // defines the size and position on image when rendering to the screen
part_rect Rect // defines the size and position of part of the image to use when rendering

View File

@ -343,7 +343,7 @@ pub const (
)
pub fn window() JS.Window {
mut x := JS.Any(voidptr(0))
mut x := JS.Any(unsafe { nil })
#x = window;
return x
@ -359,7 +359,7 @@ pub type EventCallback = fn (JS.Event)
// that is EventTarget. When you need access only to Event itself you can just use `fn (JS.Event)` as listener.
pub fn event_listener(callback fn (JS.EventTarget, JS.Event)) EventCallback {
return fn [callback] (event JS.Event) {
mut target := JS.EventTarget(voidptr(0))
mut target := JS.EventTarget(unsafe { nil })
#target = this;
callback(target, event)
}
@ -490,7 +490,7 @@ pub type OnDeviceOrientation = fn (ev JS.DeviceOrientationEvent) JS.Any
pub fn on_device_motion(cb fn (win JS.Window, ev JS.DeviceMotionEvent) JS.Any) OnDeviceMotion {
clos := fn [cb] (ev JS.DeviceMotionEvent) JS.Any {
mut win := JS.Any(voidptr(0))
mut win := JS.Any(unsafe { nil })
#win = this;
return cb(win, ev)
@ -500,7 +500,7 @@ pub fn on_device_motion(cb fn (win JS.Window, ev JS.DeviceMotionEvent) JS.Any) O
pub fn on_device_orientation(cb fn (win JS.Window, ev JS.DeviceOrientationEvent) JS.Any) OnDeviceOrientation {
clos := fn [cb] (ev JS.DeviceOrientationEvent) JS.Any {
mut win := JS.Any(voidptr(0))
mut win := JS.Any(unsafe { nil })
#win = this;
return cb(win, ev)
@ -837,7 +837,7 @@ pub fn event_type(ev JS.Event) string {
}
pub fn create_event(typ string, bubbles bool, cancelable bool, composed bool) JS.Event {
mut ev := JS.Event(voidptr(0))
mut ev := JS.Event(unsafe { nil })
#ev = new Event(typ.str,bubbles.val,cancelable.val,composed.val);
return ev

View File

@ -23,7 +23,7 @@ pub interface JS.Response {
}
pub fn fetch(input string, init map[string]JS.Any) promise.Promise<JS.Response, JS.String> {
p_init := JS.Any(voidptr(0))
p_init := JS.Any(unsafe { nil })
p := promise.Promise<JS.Response, String>{p_init}
#let obj = {}; for (let [key,val] of init.map) { obj[key] = val; }

View File

@ -158,7 +158,7 @@ pub fn (mut conn Connection) set_option(option_type int, val voidptr) {
// get_option - return the value of an option, settable by `set_option`.
// https://dev.mysql.com/doc/c-api/5.7/en/mysql-get-option.html
pub fn (conn &Connection) get_option(option_type int) ?voidptr {
ret := voidptr(0)
ret := unsafe { nil }
if C.mysql_get_option(conn.conn, option_type, &ret) != 0 {
return error_with_code(get_error_msg(conn.conn), get_errno(conn.conn))
}

View File

@ -33,7 +33,7 @@ pub fn getenv_opt(key string) ?string {
return string_from_wide(s)
} $else {
s := C.getenv(&char(key.str))
if s == voidptr(0) {
if s == nil {
return none
}
// Note: C.getenv *requires* that the result be copied.

View File

@ -264,7 +264,7 @@ pub fn vfopen(path string, mode string) ?&C.FILE {
if path.len == 0 {
return error('vfopen called with ""')
}
mut fp := voidptr(0)
mut fp := unsafe { nil }
$if windows {
fp = C._wfopen(path.to_wide(), mode.to_wide())
} $else {

View File

@ -271,7 +271,7 @@ const (
// ptr_win_get_error_msg return string (voidptr)
// representation of error, only for windows.
fn ptr_win_get_error_msg(code u32) voidptr {
mut buf := voidptr(0)
mut buf := unsafe { nil }
// Check for code overflow
if code > u32(os.max_error_code) {
return buf

View File

@ -190,7 +190,8 @@ fn (mut p Process) win_read_string(idx int, maxbytes int) (string, int) {
return '', 0
}
mut bytes_avail := int(0)
if !C.PeekNamedPipe(rhandle, voidptr(0), int(0), voidptr(0), &bytes_avail, voidptr(0)) {
if !C.PeekNamedPipe(rhandle, unsafe { nil }, int(0), unsafe { nil }, &bytes_avail,
unsafe { nil }) {
return '', 0
}
if bytes_avail == 0 {

View File

@ -57,7 +57,7 @@ pub:
port int = 8080
cb fn (voidptr, picohttpparser.Request, mut picohttpparser.Response)
err_cb fn (voidptr, picohttpparser.Request, mut picohttpparser.Response, IError) = default_err_cb
user_data voidptr = voidptr(0)
user_data voidptr = unsafe { nil }
timeout_secs int = 8
max_headers int = 100
}

View File

@ -124,10 +124,10 @@ pub fn (mut ch Channel) close() {
if !C.atomic_compare_exchange_strong_u16(&ch.closed, &open_val, 1) {
return
}
mut nulladr := unsafe { voidptr(0) }
mut nulladr := unsafe { nil }
for !C.atomic_compare_exchange_weak_ptr(unsafe { &voidptr(&ch.adr_written) }, &nulladr,
voidptr(-1)) {
nulladr = unsafe { voidptr(0) }
nulladr = unsafe { nil }
}
ch.readsem_im.post()
ch.readsem.post()
@ -191,10 +191,10 @@ fn (mut ch Channel) try_push_priv(src voidptr, no_block bool) ChanState {
{
// there is a reader waiting for us
unsafe { C.memcpy(wradr, src, ch.objsize) }
mut nulladr := unsafe { voidptr(0) }
mut nulladr := unsafe { nil }
for !C.atomic_compare_exchange_weak_ptr(unsafe { &voidptr(&ch.adr_written) },
&nulladr, wradr) {
nulladr = unsafe { voidptr(0) }
nulladr = unsafe { nil }
}
ch.readsem_im.post()
return .success
@ -382,7 +382,7 @@ fn (mut ch Channel) try_pop_priv(dest voidptr, no_block bool) ChanState {
{
// there is a writer waiting for us
unsafe { C.memcpy(dest, rdadr, ch.objsize) }
mut nulladr := unsafe { voidptr(0) }
mut nulladr := unsafe { nil }
for !C.atomic_compare_exchange_weak_ptr(unsafe { &voidptr(&ch.adr_read) },
&nulladr, rdadr) {
nulladr = unsafe { nil }

View File

@ -7,7 +7,7 @@ import runtime
fn C.atomic_fetch_add_u32(voidptr, u32) u32
pub const (
no_result = voidptr(0)
no_result = unsafe { nil }
)
pub struct PoolProcessor {
@ -48,7 +48,7 @@ pub fn new_pool_processor(context PoolProcessorConfig) &PoolProcessor {
mut pool := PoolProcessor{
items: []
results: []
shared_context: voidptr(0)
shared_context: unsafe { nil }
thread_contexts: []
njobs: context.maxjobs
ntask: 0

View File

@ -114,7 +114,7 @@ pub fn (mut ctx Context) run() ? {
}
if !ctx.paused {
sw.restart()
if ctx.cfg.event_fn != voidptr(0) {
if ctx.cfg.event_fn != unsafe { nil } {
ctx.parse_events()
}
ctx.frame()

View File

@ -233,7 +233,7 @@ fn (mut ctx Context) termios_loop() {
}
if !ctx.paused {
sw.restart()
if ctx.cfg.event_fn != voidptr(0) {
if ctx.cfg.event_fn != unsafe { nil } {
unsafe {
len := C.read(C.STDIN_FILENO, &u8(ctx.read_buf.data) + ctx.read_buf.len,
ctx.read_buf.cap - ctx.read_buf.len)

View File

@ -110,7 +110,7 @@ pub fn (t Time) local() Time {
millisecond: u16(t.microsecond / 1000)
}
st_local := SystemTime{}
C.SystemTimeToTzSpecificLocalTime(voidptr(0), &st_utc, &st_local)
C.SystemTimeToTzSpecificLocalTime(unsafe { nil }, &st_utc, &st_local)
t_local := Time{
year: st_local.year
month: st_local.month
@ -133,7 +133,7 @@ fn win_now() Time {
st_utc := SystemTime{}
C.FileTimeToSystemTime(&ft_utc, &st_utc)
st_local := SystemTime{}
C.SystemTimeToTzSpecificLocalTime(voidptr(0), &st_utc, &st_local)
C.SystemTimeToTzSpecificLocalTime(unsafe { nil }, &st_utc, &st_local)
t := Time{
year: st_local.year
month: st_local.month

View File

@ -33,7 +33,7 @@ pub mut:
used_vweb_types []Type // vweb context types, filled in by checker, when pref.skip_unused = true;
used_maps int // how many times maps were used, filled in by checker, when pref.skip_unused = true;
panic_handler FnPanicHandler = default_table_panic_handler
panic_userdata voidptr = voidptr(0) // can be used to pass arbitrary data to panic_handler;
panic_userdata voidptr = unsafe { nil } // can be used to pass arbitrary data to panic_handler;
panic_npanics int
cur_fn &FnDecl = unsafe { 0 } // previously stored in Checker.cur_fn and Gen.cur_fn
cur_concrete_types []Type // current concrete types, e.g. <int, string>

View File

@ -46,7 +46,7 @@ fn test_inspect() {
module main
'
file := parse_text(source)
walker.inspect(file, voidptr(0), fn (node &ast.Node, data voidptr) bool {
walker.inspect(file, unsafe { nil }, fn (node &ast.Node, data voidptr) bool {
// Second visit must be ast.Stmt
if node is ast.Stmt {
if node !is ast.Module {

View File

@ -144,7 +144,7 @@ pub fn (mut c Checker) return_stmt(mut node ast.Return) {
if mut r_expr is ast.Ident {
if mut r_expr.obj is ast.Var {
mut obj := unsafe { &r_expr.obj }
if c.fn_scope != voidptr(0) {
if c.fn_scope != unsafe { nil } {
obj = c.fn_scope.find_var(r_expr.obj.name) or { obj }
}
if obj.is_stack_obj && !c.inside_unsafe {

View File

@ -1,5 +1,5 @@
arr := [2, 3]!
mut p := voidptr(0)
mut p := unsafe { nil }
p = arr
mut ip := &int(0)
ip = arr

View File

@ -1,7 +1,7 @@
// void* arithmetic is not allowed in MSVC, so ban it
fn test_voidptr() {
unsafe {
mut p := voidptr(0)
mut p := nil
_ = p + 1
p++
p += 3

View File

@ -1,5 +1,5 @@
fn main() {
mut a := voidptr(0)
mut a := unsafe { nil }
mut b := 123
a = &b
println(*a)

View File

@ -38,7 +38,7 @@ pub struct NewNodeConfig {
node_name string
should_highlight bool
tooltip string
ctx voidptr = voidptr(0)
ctx voidptr = unsafe { nil }
name2node_fn FnLabel2NodeName = node_name
}
@ -58,7 +58,7 @@ pub fn (mut d DotGraph) new_node(nlabel string, cfg NewNodeConfig) {
pub struct NewEdgeConfig {
should_highlight bool
ctx voidptr = voidptr(0)
ctx voidptr = unsafe { nil }
name2node_fn FnLabel2NodeName = node_name
}

View File

@ -2,14 +2,13 @@ import v.ast { InfixExpr }
import v.table { Type }
fn test_as() {
_ := sum_expr() as ast.InfixExpr
_ := sum_expr() as InfixExpr
_ := sum_expr() as ast.PrefixExpr
}
fn test_cast() {
_ := f32(0)
_ := table.Type(0)
_ := Type(0)
_ := ast.Expr(sum_expr())
_ := voidptr(0)
_ := unsafe { nil }
}

View File

@ -17,10 +17,10 @@ pub type MouseMoveFn = fn (e MouseMoveEvent, func voidptr)
[heap]
pub struct Window {
pub mut:
ui &UI = voidptr(0)
ui &UI = unsafe { nil }
children []Widget
child_window &Window = voidptr(0)
parent_window &Window = voidptr(0)
child_window &Window = unsafe { nil }
parent_window &Window = unsafe { nil }
has_textbox bool // for initial focus
tab_index int
just_tabbed bool

View File

@ -158,7 +158,7 @@ fn (mut g Gen) assign_stmt(node_ ast.AssignStmt) {
ret_styp := g.typ(val.decl.return_type)
g.write('$ret_styp (*$ident.name) (')
def_pos := g.definitions.len
g.fn_decl_params(val.decl.params, voidptr(0), false)
g.fn_decl_params(val.decl.params, unsafe { nil }, false)
g.definitions.go_back(g.definitions.len - def_pos)
g.write(') = ')
} else {
@ -344,7 +344,7 @@ fn (mut g Gen) assign_stmt(node_ ast.AssignStmt) {
g.write('$ret_styp ($msvc_call_conv*${g.get_ternary_name(ident.name)}) (')
def_pos := g.definitions.len
g.fn_decl_params(func.func.params, voidptr(0), false)
g.fn_decl_params(func.func.params, unsafe { nil }, false)
g.definitions.go_back(g.definitions.len - def_pos)
g.write(')$call_conv_attribute_suffix')
} else {

View File

@ -44,7 +44,7 @@ pub mut:
in_lambda_depth int
inside_const bool
is_mbranch_expr bool // match a { x...y { } }
fn_scope &ast.Scope = voidptr(0)
fn_scope &ast.Scope = unsafe { nil }
wsinfix_depth int
nlines int
}

View File

@ -1124,7 +1124,7 @@ fn (mut g JsGen) gen_ctemp_var(tvar ast.CTempVar) {
fn (mut g JsGen) gen_assert_metainfo(node ast.AssertStmt) string {
mod_path := g.file.path
fn_name := if g.fn_decl == voidptr(0) || g.fn_decl.is_anon { 'anon' } else { g.fn_decl.name }
fn_name := if g.fn_decl == unsafe { nil } || g.fn_decl.is_anon { 'anon' } else { g.fn_decl.name }
line_nr := node.pos.line_nr
src := node.expr.str()
metaname := 'v_assert_meta_info_$g.new_tmp_var()'
@ -1244,7 +1244,7 @@ fn (mut g JsGen) gen_assert_stmt(mut node ast.AssertStmt) {
}
g.writeln('} else {')
g.inc_indent()
fname := if g.fn_decl == voidptr(0) || g.fn_decl.is_anon { 'anon' } else { g.fn_decl.name }
fname := if g.fn_decl == unsafe { nil } || g.fn_decl.is_anon { 'anon' } else { g.fn_decl.name }
g.writeln('builtin__eprintln(new string("$mod_path:${node.pos.line_nr + 1}: FAIL: fn ${fname}(): assert $s_assertion"));')
g.writeln('builtin__exit(1);')
g.dec_indent()

View File

@ -102,7 +102,7 @@ pub fn change_test_runner(x &TestRunner) {
if pobj != 0 {
test_runner.free()
unsafe {
(&C.main__TestRunner(&test_runner))._object = voidptr(0)
(&C.main__TestRunner(&test_runner))._object = nil
}
}
test_runner = *x

View File

@ -2,7 +2,7 @@ struct Abc {
prev &Abc
}
const a = [Abc{voidptr(0)}, Abc{unsafe { &a[0] }}, Abc{unsafe { &a[1] }}]!
const a = [Abc{unsafe { nil }}, Abc{unsafe { &a[0] }}, Abc{unsafe { &a[1] }}]!
fn test_fixed_array() {
eprintln(a)

View File

@ -15,7 +15,7 @@ struct Abc {
fn (a Abc) xyz() {}
fn resource__null() &IAbc {
return voidptr(0)
return unsafe { nil }
}
fn test_fn_returning_voidptr_casted_as_interface_works() {

View File

@ -15,5 +15,5 @@ fn test_passing_voidptr_as_an_interface_reference() {
assert f(&i) == '&IAbc(Abc{})'
// a voidptr() cast is an escape hatch, that should be allowed
// but perhaps it should be forced by the compiler to be in unsafe{}
assert f(unsafe { voidptr(0) }) == '&IAbc(0x0)'
assert f(unsafe { nil }) == '&IAbc(0x0)'
}

View File

@ -15,7 +15,7 @@ fn f(i &IAbc) string {
}
fn test_voidptr_casted_as_an_interface_reference() {
mut pi := &IAbc(voidptr(0))
mut pi := &IAbc(unsafe { nil })
dump(pi)
assert f(pi) == '&IAbc(0x0)'
//

View File

@ -45,7 +45,7 @@ interface PopView {
[heap]
pub struct Button {
mut:
window &Window = voidptr(0)
window &Window = unsafe { nil }
}
pub fn (mut b Button) init(window &Window) {

View File

@ -1,5 +1,5 @@
fn multi_voidptr_ret() (voidptr, bool) {
return voidptr(0), true
return unsafe { nil }, true
}
fn multi_byteptr_ret() (&u8, bool) {

View File

@ -3,24 +3,24 @@ struct Zest {
}
fn (t Zest) get_a_finger_to_the_moon() voidptr {
return voidptr(0)
return unsafe { nil }
}
fn get_the_dao_way() voidptr {
return voidptr(0)
return unsafe { nil }
}
fn test_returning_a_void_pointer_from_a_method() {
t := &Zest{
val: 123
}
z := voidptr(0)
z := unsafe { nil }
assert z == t.get_a_finger_to_the_moon()
assert t.get_a_finger_to_the_moon() == 0
}
fn test_returning_a_void_pointer_from_a_function() {
z := voidptr(0)
z := unsafe { nil }
assert z == get_the_dao_way()
assert get_the_dao_way() == 0
}

View File

@ -4,7 +4,7 @@ type Fnc = fn ()
struct Foo {
Bar
fnc_fn Fnc = voidptr(0)
fnc_fn Fnc = unsafe { nil }
}
struct App {

View File

@ -7,6 +7,6 @@
fn main() {
mut y := unsafe { malloc(1000) }
// unsafe { free(y) } // leak if commented out
y = voidptr(0)
y = unsafe { nil }
gc_check_leaks()
}