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:
parent
0a78847782
commit
71edaa071a
@ -124,7 +124,7 @@ fn (mut a array) ensure_cap(required int) {
|
|||||||
cap *= 2
|
cap *= 2
|
||||||
}
|
}
|
||||||
new_size := cap * a.element_size
|
new_size := cap * a.element_size
|
||||||
new_data := vcalloc(new_size)
|
new_data := unsafe { malloc(new_size) }
|
||||||
if a.data != voidptr(0) {
|
if a.data != voidptr(0) {
|
||||||
unsafe { vmemcpy(new_data, a.data, a.len * a.element_size) }
|
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?)
|
// TODO: the old data may be leaked when no GC is used (ref-counting?)
|
||||||
|
Loading…
Reference in New Issue
Block a user