diff --git a/vlib/net/http/header.v b/vlib/net/http/header.v index 641dec31e2..9fb919de89 100644 --- a/vlib/net/http/header.v +++ b/vlib/net/http/header.v @@ -325,6 +325,12 @@ mut: data map[string][]string } +pub fn (mut h Header) free() { + unsafe { + h.data.free() + } +} + pub struct HeaderConfig { key CommonHeader value string diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index f0cc8c67c3..4c37bb9fab 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -4642,12 +4642,16 @@ fn (mut g Gen) const_decl_init_later(mod string, name string, val string, typ ta } } if g.is_autofree { + sym := g.table.get_type_symbol(typ) if styp.starts_with('Array_') { g.cleanups[mod].writeln('\tarray_free(&$cname);') } - if styp == 'string' { + else if styp == 'string' { g.cleanups[mod].writeln('\tstring_free(&$cname);') } + else if sym.kind == .map { + g.cleanups[mod].writeln('\tmap_free(&$cname);') + } } } diff --git a/vlib/vweb/request.v b/vlib/vweb/request.v index 0083eec291..f0e20d824f 100644 --- a/vlib/vweb/request.v +++ b/vlib/vweb/request.v @@ -38,6 +38,7 @@ fn parse_request(mut reader io.BufferedReader) ?http.Request { reader.read(mut body) or {} } } + h.free() return http.Request{ method: method diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index 3b1ca1bbc4..86e5cd8576 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -298,6 +298,8 @@ pub fn run_app(mut app T, port int) { } } + +[manualfree] fn handle_conn(mut conn net.TcpConn, mut app T) { conn.set_read_timeout(30 * time.second) conn.set_write_timeout(30 * time.second)