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

cgen: implement IError.free() and use it for the builtin none const

This commit is contained in:
Delyan Angelov
2021-03-17 12:31:36 +02:00
parent 2e84773ef1
commit 99cc02685b
2 changed files with 29 additions and 2 deletions

View File

@@ -62,3 +62,27 @@ fn opt_ok(data voidptr, mut option Option, size int) {
C.memcpy(byteptr(&option.err) + sizeof(IError), data, size)
}
}
[unsafe]
pub fn (e &Error) free() {
unsafe { e.msg.free() }
}
[unsafe]
pub fn (n &None__) free() {
unsafe { n.msg.free() }
}
[typedef]
struct C.IError {
_object voidptr
}
[unsafe]
pub fn (ie &IError) free() {
unsafe {
ie.msg.free()
cie := &C.IError(ie)
C.free(cie._object)
}
}