mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: require unsafe for free()
This commit is contained in:
parent
fa447443ca
commit
46f32fc10c
@ -47,7 +47,9 @@ fn (mut a App) init() {
|
||||
}
|
||||
|
||||
fn (mut a App) cleanup() {
|
||||
a.ps.free()
|
||||
unsafe {
|
||||
a.ps.free()
|
||||
}
|
||||
}
|
||||
|
||||
fn (mut a App) run() {
|
||||
|
@ -26,7 +26,9 @@ fn handle_client(mut socket net.TcpConn) {
|
||||
eprintln('> new client: $client_addr')
|
||||
mut reader := io.new_buffered_reader(reader: socket)
|
||||
defer {
|
||||
reader.free()
|
||||
unsafe {
|
||||
reader.free()
|
||||
}
|
||||
}
|
||||
socket.write_string('server: hello\n') or { return }
|
||||
for {
|
||||
|
@ -470,7 +470,9 @@ fn frame(x voidptr) {
|
||||
|
||||
fn cleanup(x voidptr) {
|
||||
mut app := &App(x)
|
||||
app.free()
|
||||
unsafe {
|
||||
app.free()
|
||||
}
|
||||
}
|
||||
|
||||
fn fail(error string) {
|
||||
|
@ -23,7 +23,9 @@ pub fn (mut cb Clipboard) clear_all() {
|
||||
|
||||
// destroy destroys the clipboard and frees its resources.
|
||||
pub fn (mut cb Clipboard) destroy() {
|
||||
cb.free()
|
||||
unsafe {
|
||||
cb.free()
|
||||
}
|
||||
}
|
||||
|
||||
// check_ownership returns `true` if the `Clipboard` has the content ownership.
|
||||
|
@ -88,7 +88,9 @@ fn (mut s Server) parse_and_respond(mut conn net.TcpConn) {
|
||||
|
||||
mut reader := io.new_buffered_reader(reader: conn)
|
||||
defer {
|
||||
reader.free()
|
||||
unsafe {
|
||||
reader.free()
|
||||
}
|
||||
}
|
||||
req := parse_request(mut reader) or {
|
||||
$if debug {
|
||||
|
@ -1164,6 +1164,10 @@ pub fn (mut c Checker) method_call(mut node ast.CallExpr) ast.Type {
|
||||
return ast.int_type
|
||||
}
|
||||
}
|
||||
if !c.is_builtin_mod && !c.inside_unsafe && method_name == 'free' {
|
||||
c.warn('manual memory management with `free()` is only allowed in unsafe code',
|
||||
node.pos)
|
||||
}
|
||||
if left_type == ast.void_type {
|
||||
// No need to print this error, since this means that the variable is unknown,
|
||||
// and there already was an error before.
|
||||
|
@ -100,8 +100,8 @@ mut:
|
||||
pub fn change_test_runner(x &TestRunner) {
|
||||
pobj := unsafe { &C.main__TestRunner(&test_runner)._object }
|
||||
if pobj != 0 {
|
||||
test_runner.free()
|
||||
unsafe {
|
||||
test_runner.free()
|
||||
(&C.main__TestRunner(&test_runner))._object = nil
|
||||
}
|
||||
}
|
||||
|
@ -442,7 +442,9 @@ fn handle_conn<T>(mut conn net.TcpConn, mut app T, routes map[string]Route) {
|
||||
|
||||
mut reader := io.new_buffered_reader(reader: conn)
|
||||
defer {
|
||||
reader.free()
|
||||
unsafe {
|
||||
reader.free()
|
||||
}
|
||||
}
|
||||
|
||||
page_gen_start := time.ticks()
|
||||
|
Loading…
Reference in New Issue
Block a user