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

io: BufferedReader.free()

This commit is contained in:
Alexander Medvednikov 2021-03-15 21:25:19 +01:00
parent 667a26335f
commit 852d302b87
2 changed files with 9 additions and 0 deletions

View File

@ -55,6 +55,12 @@ pub fn (mut r BufferedReader) read(mut buf []byte) ?int {
return read
}
pub fn (mut r BufferedReader) free() {
unsafe {
r.buf.free()
}
}
// fill_buffer attempts to refill the internal buffer
// and returns whether it got any data
fn (mut r BufferedReader) fill_buffer() bool {

View File

@ -305,6 +305,9 @@ fn handle_conn<T>(mut conn net.TcpConn, mut app T) {
conn.close() or {}
}
mut reader := io.new_buffered_reader(reader: io.make_reader(conn))
defer {
reader.free()
}
page_gen_start := time.ticks()
req := parse_request(mut reader) or {
eprintln('error parsing request: $err')