void DArray_Erase( DArray *self, daoint start, daoint n ) { void **buf = self->items.pVoid - self->offset; daoint rest, locked; if( start >= self->size ) return; if( n < 0 ) n = self->size; if( n > self->size - start ) n = self->size - start; if( n == 1 ){ if( start == 0 ){ DArray_PopFront( self ); return; }else if( start == self->size -1 ){ DArray_PopBack( self ); return; } } DArray_DeleteItems( self, start, start+n ); rest = self->size - start - n; locked = self->type == DAO_DATA_VALUE ? DaoGC_LockArray( self ) : 0; memmove( self->items.pVoid + start, self->items.pVoid + start + n, rest * sizeof(void*) ); self->size -= n; if( self->size < 0.5*self->bufsize && self->size + 10 < self->bufsize ){ if( self->offset ) memmove( buf, self->items.pVoid, self->size * sizeof(void*)); self->bufsize = 0.6 * self->bufsize + 1; self->items.pVoid = (void**) dao_realloc( buf, (self->bufsize+1)*sizeof(void*) ); self->offset = 0; } DaoGC_UnlockArray( self, locked ); }
static DaoTaskEvent* DaoCallServer_MakeEvent() { DaoTaskEvent *event; DaoCallServer *server = daoCallServer; DMutex_Lock( & server->mutex ); event = (DaoTaskEvent*) DArray_PopBack( server->caches ); if( event == NULL ) event = DaoTaskEvent_New(); DMutex_Unlock( & server->mutex ); return event; }
DaoxDataColumn* DaoxDataFrame_MakeColumn( DaoxDataFrame *self, DaoType *type ) { DaoxDataColumn *column = (DaoxDataColumn*) DArray_Back( self->caches ); if( self->caches->size ){ DaoxDataColumn_SetType( column, type ); DArray_PopBack( self->caches ); return column; } return DaoxDataColumn_New( type ); }