示例#1
0
文件: readers.c 项目: Moteesh/reactos
/* 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;
}
示例#2
0
文件: reader.c 项目: jeefo/xash3d
// 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;
}
示例#3
0
/* Fetch a buffer from the pool (if possible) or create one. */
static struct buffy* bc_alloc(struct bufferchain *bc, size_t size)
{
	/* Easy route: Just try the first available buffer.
	   Size does not matter, it's only a hint for creation of new buffers. */
	if(bc->pool)
	{
		struct buffy *buf = bc->pool;
		bc->pool = buf->next;
		buf->next = NULL; /* That shall be set to a sensible value later. */
		buf->size = 0;
		--bc->pool_fill;
		return buf;
	}
	else return buffy_new(size, bc->bufblock);
}
示例#4
0
文件: reader.c 项目: jeefo/xash3d
// fetch a buffer from the pool (if possible) or create one.
static buffy_t* bc_alloc( bufferchain_t *bc, size_t size )
{
	// Easy route: Just try the first available buffer.
	// size does not matter, it's only a hint for creation of new buffers.
	if( bc->pool )
	{
		buffy_t *buf = bc->pool;

		bc->pool = buf->next;
		buf->next = NULL; // that shall be set to a sensible value later. 
		buf->size = 0;
		bc->pool_fill--;

		return buf;
	}

	return buffy_new( size, bc->bufblock );
}