Fixed incorrect parameters for memory deallocation
This commit is contained in:
parent
ade1fd8fff
commit
b1228be79a
@ -1,10 +1,4 @@
|
|||||||
import mem
|
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
text := mem.alloc(4)
|
text := "Hi!\0"
|
||||||
text[0] = 'H'
|
user32.MessageBoxA(0, text, text, 0x240040)
|
||||||
text[1] = 'i'
|
|
||||||
text[2] = '!'
|
|
||||||
user32.MessageBoxA(0, text, text, 0x00240040)
|
|
||||||
mem.free(text, 4)
|
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
free(address Pointer, length Int) -> Int {
|
free(address Pointer, length Int) -> Int {
|
||||||
return sys.munmap(address, length)
|
return sys.munmap(address-8, length+8)
|
||||||
}
|
}
|
7
tests/programs/memory-free.q
Normal file
7
tests/programs/memory-free.q
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import mem
|
||||||
|
|
||||||
|
main() {
|
||||||
|
address := mem.alloc(1024)
|
||||||
|
err := mem.free(address, 1024)
|
||||||
|
assert err == 0
|
||||||
|
}
|
@ -59,6 +59,7 @@ var programs = []struct {
|
|||||||
{"switch", "", "", 0},
|
{"switch", "", "", 0},
|
||||||
{"loop", "", "", 0},
|
{"loop", "", "", 0},
|
||||||
{"loop-lifetime", "", "", 0},
|
{"loop-lifetime", "", "", 0},
|
||||||
|
{"memory-free", "", "", 0},
|
||||||
{"out-of-memory", "", "", 0},
|
{"out-of-memory", "", "", 0},
|
||||||
{"struct", "", "", 0},
|
{"struct", "", "", 0},
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user