don't shrink in array_allocate

master
leitner 20 years ago
parent e1e80badf0
commit 12caccfd48

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

@ -75,6 +75,11 @@ int64 io_waituntil2(int64 milliseconds) {
if ((n=kevent(io_master,0,0,y,100,milliseconds!=-1?&ts:0))==-1) return -1; if ((n=kevent(io_master,0,0,y,100,milliseconds!=-1?&ts:0))==-1) return -1;
for (i=n-1; i>=0; --i) { for (i=n-1; i>=0; --i) {
io_entry* e=array_get(&io_fds,sizeof(io_entry),y[--n].ident); io_entry* e=array_get(&io_fds,sizeof(io_entry),y[--n].ident);
#ifdef DEBUG
if (!e) {
e=e;
}
#endif
if (e) { if (e) {
if (y[n].flags&EV_ERROR) { if (y[n].flags&EV_ERROR) {
/* error; signal whatever app is looking for */ /* error; signal whatever app is looking for */

Loading…
Cancel
Save