all: various fixes for [heap]/auto-heap handling (#10033)

This commit is contained in:
Uwe Krüger 2021-05-07 14:58:48 +02:00 committed by GitHub
parent 5b4eef8010
commit d26ac5692e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 279 additions and 149 deletions

View file

@ -9,7 +9,7 @@ pub fn memcpy(dest &C.void, src &C.void, n size_t) &C.void {
dest_[i] = src_[i]
}
}
return dest
return unsafe { dest }
}
[export: 'malloc']
@ -37,7 +37,7 @@ fn realloc(old_area &C.void, new_size size_t) &C.void {
}
old_size := unsafe { *(&u64(old_area - sizeof(u64))) }
if u64(new_size) <= old_size {
return old_area
return unsafe { old_area }
} else {
new_area := unsafe { malloc(int(new_size)) }
unsafe { memmove(new_area, old_area, size_t(old_size)) }
@ -54,7 +54,7 @@ fn memset(s &C.void, c int, n size_t) &C.void {
s_[i] = char(c)
}
}
return s
return unsafe { s }
}
[unsafe]
@ -74,7 +74,7 @@ fn memmove(dest &C.void, src &C.void, n size_t) &C.void {
}
}
unsafe { free(temp_buf) }
return dest
return unsafe { dest }
}
[export: 'calloc']