sync,strings,cgen: reduce memory consumption in cgen

This commit is contained in:
Delyan Angelov 2021-10-29 21:01:07 +03:00
parent 7e0f2fcda9
commit a7d4236337
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED
4 changed files with 133 additions and 58 deletions

View file

@ -159,5 +159,11 @@ pub fn (mut b Builder) str() string {
// free is for manually freeing the contents of the buffer
[unsafe]
pub fn (mut b Builder) free() {
unsafe { free(b.data) }
if b.data != 0 {
unsafe { free(b.data) }
mut pd := &b.data
unsafe {
(*pd) = voidptr(0)
}
}
}