diff options
author | eddyg <[email protected]> | 2007-10-04 00:44:41 +0000 |
---|---|---|
committer | eddyg <[email protected]> | 2007-10-04 00:44:41 +0000 |
commit | e20b60acb5d0fd0eec5c28b631c0f61286ee5961 (patch) | |
tree | 7f0b73eff548d70ffea091cef4bca90e3030346d /libhb/fifo.c | |
parent | 7b750d30e23312c7c9924be13b81c0b8c9296c99 (diff) |
Two changes, one ensure zero size buffers are zero size, second change the buffer cleanup to be later.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@999 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/fifo.c')
-rw-r--r-- | libhb/fifo.c | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/libhb/fifo.c b/libhb/fifo.c index a36bb7774..4f844795c 100644 --- a/libhb/fifo.c +++ b/libhb/fifo.c @@ -93,39 +93,42 @@ hb_buffer_t * hb_buffer_init( int size ) int b_alloc; int resize = 0; - /* - * The buffer pools are allocated in increasing size - */ - for( i = 0; i < buffers.entries; i++ ) + if( size > 0 ) { - if( buffers.pool[i]->buffer_size >= size ) + /* + * The buffer pools are allocated in increasing size + */ + for( i = 0; i < buffers.entries; i++ ) { - /* - * This pool is big enough, but are there any buffers in it? - */ - if( hb_fifo_size( buffers.pool[i] ) ) + if( buffers.pool[i]->buffer_size >= size ) { /* - * We've found a matching buffer pool, with buffers. - */ - buffer_pool = buffers.pool[i]; - resize = buffers.pool[i]->buffer_size; - } else { - /* - * Buffer pool is empty, + * This pool is big enough, but are there any buffers in it? */ - if( resize ) { + if( hb_fifo_size( buffers.pool[i] ) ) + { /* - * This is the second time through, so break out of here to avoid - * using too large a buffer for a small job. + * We've found a matching buffer pool, with buffers. */ - break; + buffer_pool = buffers.pool[i]; + resize = buffers.pool[i]->buffer_size; + } else { + /* + * Buffer pool is empty, + */ + if( resize ) { + /* + * This is the second time through, so break + * out of here to avoid using too large a + * buffer for a small job. + */ + break; + } + resize = buffers.pool[i]->buffer_size; } - resize = buffers.pool[i]->buffer_size; } } } - /* * Don't reuse the 0 size buffers, not much gain. */ |