1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

builtin: use malloc, instead of calloc in array.ensure_cap/1

This commit is contained in:
Delyan Angelov 2022-03-20 15:02:15 +02:00
parent 0a78847782
commit 71edaa071a
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -124,7 +124,7 @@ fn (mut a array) ensure_cap(required int) {
cap *= 2
}
new_size := cap * a.element_size
new_data := vcalloc(new_size)
new_data := unsafe { malloc(new_size) }
if a.data != voidptr(0) {
unsafe { vmemcpy(new_data, a.data, a.len * a.element_size) }
// TODO: the old data may be leaked when no GC is used (ref-counting?)