| 278 | #endif |
| 279 | |
| 280 | void hb_buffer_pool_free( void ) |
| 281 | { |
| 282 | int i; |
| 283 | int64_t freed = 0; |
| 284 | |
| 285 | hb_lock(buffers.lock); |
| 286 | |
| 287 | #if defined(HB_BUFFER_DEBUG) |
| 288 | hb_deep_log(2, "leaked %d buffers", hb_list_count(buffers.alloc_list)); |
| 289 | for (i = 0; i < hb_list_count(buffers.alloc_list); i++) |
| 290 | { |
| 291 | hb_buffer_t *b = hb_list_item(buffers.alloc_list, i); |
| 292 | hb_deep_log(2, "leaked buffer %p type %d size %d alloc %d", |
| 293 | b, b->s.type, b->size, b->alloc); |
| 294 | } |
| 295 | #endif |
| 296 | |
| 297 | #if !defined(HB_NO_BUFFER_POOL) |
| 298 | hb_buffer_t * b; |
| 299 | int count; |
| 300 | for( i = BUFFER_POOL_FIRST; i <= BUFFER_POOL_LAST; ++i) |
| 301 | { |
| 302 | count = 0; |
| 303 | while( ( b = hb_fifo_get(buffers.pool[i]) ) ) |
| 304 | { |
| 305 | if( b->data ) |
| 306 | { |
| 307 | freed += b->alloc; |
| 308 | av_free(b->data); |
| 309 | } |
| 310 | free( b ); |
| 311 | count++; |
| 312 | } |
| 313 | if ( count ) |
| 314 | { |
| 315 | hb_deep_log( 2, "Freed %d buffers of size %d", count, |
| 316 | buffers.pool[i]->buffer_size); |
| 317 | } |
| 318 | } |
| 319 | #endif |
| 320 | |
| 321 | #if defined(HB_BUFFER_DEBUG) && defined(HB_NO_BUFFER_POOL) |
| 322 | // defining HB_BUFFER_DEBUG and HB_NO_BUFFER_POOL allows tracking |
| 323 | // buffer memory leaks using valgrind. The source of the leak |
| 324 | // can be determined with "valgrind --leak-check=full" |
| 325 | for (i = 0; i < hb_list_count(buffers.alloc_list); i++) |
| 326 | { |
| 327 | hb_buffer_t *b = hb_list_item(buffers.alloc_list, i); |
| 328 | hb_list_rem(buffers.alloc_list, b); |
| 329 | } |
| 330 | #endif |
| 331 | |
| 332 | hb_deep_log( 2, "Allocated %"PRId64" bytes of buffers on this pass and Freed %"PRId64" bytes, " |
| 333 | "%"PRId64" bytes leaked", buffers.allocated, freed, buffers.allocated - freed); |
| 334 | buffers.allocated = 0; |
| 335 | hb_unlock(buffers.lock); |
| 336 | } |
| 337 |
no test coverage detected