/* Make the buffer count in the pool match the pool size. */ static int bc_fill_pool(struct bufferchain *bc) { /* Remove superfluous ones. */ while(bc->pool_fill > bc->pool_size) { /* Lazyness: Just work on the front. */ struct buffy* buf = bc->pool; bc->pool = buf->next; buffy_del(buf); --bc->pool_fill; } /* Add missing ones. */ while(bc->pool_fill < bc->pool_size) { /* Again, just work on the front. */ struct buffy* buf; buf = buffy_new(0, bc->bufblock); /* Use default block size. */ if(!buf) return -1; buf->next = bc->pool; bc->pool = buf; ++bc->pool_fill; } return 0; }
// make the buffer count in the pool match the pool size. static int bc_fill_pool( bufferchain_t *bc ) { // remove superfluous ones. while( bc->pool_fill > bc->pool_size ) { // lazyness: Just work on the front. buffy_t *buf = bc->pool; bc->pool = buf->next; buffy_del( buf ); bc->pool_fill--; } // add missing ones. while( bc->pool_fill < bc->pool_size ) { // again, just work on the front. buffy_t *buf = buffy_new( 0, bc->bufblock ); // use default block size. if( !buf ) return -1; buf->next = bc->pool; bc->pool = buf; bc->pool_fill++; } return 0; }
/* Delete this buffy and all following buffies. */ static void buffy_del_chain(struct buffy* buf) { while(buf) { struct buffy* next = buf->next; buffy_del(buf); buf = next; } }
// delete this buffy and all following buffies. static void buffy_del_chain( buffy_t *buf ) { while( buf ) { buffy_t *next = buf->next; buffy_del( buf ); buf = next; } }
/* Either stuff the buffer back into the pool or free it for good. */ static void bc_free(struct bufferchain *bc, struct buffy* buf) { if(!buf) return; if(bc->pool_fill < bc->pool_size) { buf->next = bc->pool; bc->pool = buf; ++bc->pool_fill; } else buffy_del(buf); }
// either stuff the buffer back into the pool or free it for good. static void bc_free( bufferchain_t *bc, buffy_t* buf ) { if( !buf ) return; if( bc->pool_fill < bc->pool_size ) { buf->next = bc->pool; bc->pool = buf; bc->pool_fill++; } else buffy_del( buf ); }