mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builtin: new_array: cap should not be less than len
This commit is contained in:
@@ -142,10 +142,13 @@ pub fn v_calloc(n int) byteptr {
|
||||
}
|
||||
|
||||
pub fn vcalloc(n int) byteptr {
|
||||
if n <= 0 {
|
||||
if n < 0 {
|
||||
panic('calloc(<=0)')
|
||||
} else if n == 0 {
|
||||
return byteptr(0)
|
||||
} else {
|
||||
return C.calloc(n, 1)
|
||||
}
|
||||
return C.calloc(n, 1)
|
||||
}
|
||||
|
||||
[unsafe_fn]
|
||||
|
||||
Reference in New Issue
Block a user