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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user