|
|
|
@ -56,6 +56,7 @@ void* array_allocate(array* x,uint64 membersize,int64 pos) {
|
|
|
|
|
/* second case of overflow: pos*membersize too large */
|
|
|
|
|
if (__unlikely(!umult64(membersize,pos+1,&wanted))) return 0;
|
|
|
|
|
|
|
|
|
|
if (wanted > (uint64)x->initialized) {
|
|
|
|
|
if (__unlikely(wanted >= (uint64)x->allocated)) {
|
|
|
|
|
/* round up a little */
|
|
|
|
|
if (membersize<8)
|
|
|
|
@ -76,5 +77,7 @@ void* array_allocate(array* x,uint64 membersize,int64 pos) {
|
|
|
|
|
byte_zero(x->p+x->initialized,x->allocated-x->initialized);
|
|
|
|
|
}
|
|
|
|
|
x->initialized=(pos+1)*membersize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return x->p+pos*membersize;
|
|
|
|
|
}
|
|
|
|
|