mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vweb: fix a leak
This commit is contained in:
parent
b04e509830
commit
0138f46797
@ -115,6 +115,7 @@ pub fn (mut b Builder) str() string {
|
||||
b.buf << `\0`
|
||||
s := string(b.buf,b.len)
|
||||
bis := b.initial_size
|
||||
//free(b.buf.data)
|
||||
b.buf = []byte{cap: bis}
|
||||
b.len = 0
|
||||
return s
|
||||
|
@ -437,6 +437,17 @@ fn (mut g Gen) sub8_var(reg Register, var_offset int) {
|
||||
g.println('sub8 $reg,DWORD PTR[rbp-$var_offset.hex2()]')
|
||||
}
|
||||
|
||||
fn (mut g Gen) mul8_var(reg Register, var_offset int) {
|
||||
g.write8(0x0f)
|
||||
g.write8(0xaf)
|
||||
match reg {
|
||||
.eax, .rax { g.write8(0x45) }
|
||||
else { verror('mul8_var') }
|
||||
}
|
||||
g.write8(0xff - var_offset + 1)
|
||||
g.println('mul8 $reg,DWORD PTR[rbp-$var_offset.hex2()]')
|
||||
}
|
||||
|
||||
fn (mut g Gen) leave() {
|
||||
g.write8(0xc9)
|
||||
g.println('leave')
|
||||
@ -732,6 +743,7 @@ fn (mut g Gen) infix_expr(node ast.InfixExpr) {
|
||||
var_offset := g.get_var_offset(ident.name)
|
||||
match node.op {
|
||||
.plus { g.add8_var(.eax, var_offset) }
|
||||
.mul { g.mul8_var(.eax, var_offset) }
|
||||
.minus { g.sub8_var(.eax, var_offset) }
|
||||
else {}
|
||||
}
|
||||
|
@ -11,11 +11,19 @@ fn print_number(n int) {
|
||||
if n == 9 { println('9') }
|
||||
}
|
||||
|
||||
struct User {
|
||||
age int
|
||||
}
|
||||
|
||||
fn print_user(u User) {
|
||||
|
||||
}
|
||||
|
||||
fn test_add() {
|
||||
println('test_add()')
|
||||
x := 2
|
||||
y := 3
|
||||
z := x + y
|
||||
y :=3
|
||||
z := x * y
|
||||
q := y - x
|
||||
print_number(x)
|
||||
print_number(y)
|
||||
@ -26,5 +34,5 @@ fn test_add() {
|
||||
fn main() {
|
||||
println('start')
|
||||
test_add()
|
||||
println('end')
|
||||
println('end1l')
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ fn (mut ctx Context) send_response_to_client(mimetype string, res string) bool {
|
||||
if ctx.done { return false }
|
||||
ctx.done = true
|
||||
mut sb := strings.new_builder(1024)
|
||||
defer { sb.free() }
|
||||
sb.write('HTTP/1.1 200 OK\r\nContent-Type: ') sb.write(mimetype)
|
||||
sb.write('\r\nContent-Length: ') sb.write(res.len.str())
|
||||
sb.write(ctx.headers)
|
||||
@ -65,7 +66,7 @@ fn (mut ctx Context) send_response_to_client(mimetype string, res string) bool {
|
||||
sb.write(headers_close)
|
||||
sb.write(res)
|
||||
ctx.conn.send_string(sb.str()) or { return false }
|
||||
sb.free()
|
||||
//sb.free()
|
||||
return true
|
||||
}
|
||||
|
||||
@ -304,6 +305,7 @@ fn handle_conn<T>(conn net.Socket, mut app T) {
|
||||
return
|
||||
}
|
||||
app.vweb.send_response_to_client(mime_type, data)
|
||||
data.free()
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user