| 560 | |
| 561 | #ifdef VALIDATE_MEMORY_POOL |
| 562 | void |
| 563 | MemoryPool::validate_pool(MemoryPool& pool, bool log) { |
| 564 | AllocHeader* prev = 0; |
| 565 | size_t allocated_bytes = 0; |
| 566 | size_t free_bytes = 0; |
| 567 | size_t oh_bytes = 0; |
| 568 | size_t free_count = 0; |
| 569 | unsigned char* pool_end = pool.pool_ptr_ + pool.pool_size_; |
| 570 | bool prev_was_free; |
| 571 | size_t index = 0; |
| 572 | |
| 573 | typedef std::map<FreeHeader*, int> FreeMap; |
| 574 | FreeMap free_map; |
| 575 | // Gather all free indices |
| 576 | AllocHeader* alloc = reinterpret_cast<AllocHeader*>(pool.pool_ptr_); |
| 577 | while (pool.includes(alloc)) { |
| 578 | FreeHeader* free_header = alloc->is_free() ? |
| 579 | reinterpret_cast<FreeHeader*>(alloc) : NULL; |
| 580 | if (free_header) { |
| 581 | free_map[free_header] = index; |
| 582 | } |
| 583 | alloc = alloc->next_adjacent(); |
| 584 | ++index; |
| 585 | } |
| 586 | |
| 587 | index = 0; |
| 588 | if (log) { |
| 589 | ACE_OS::printf("Pool ptr %zx end %zx\n", (unsigned long)pool.pool_ptr_, |
| 590 | (unsigned long)pool_end); |
| 591 | } |
| 592 | |
| 593 | // Check all allocs in positional order and not overlapping |
| 594 | alloc = reinterpret_cast<AllocHeader*>(pool.pool_ptr_); |
| 595 | while (pool.includes(alloc)) { |
| 596 | if (log) { |
| 597 | |
| 598 | int smlr_index = -1; |
| 599 | int lrgr_index = -1; |
| 600 | char lrgr_buff[32]; |
| 601 | char smlr_buff[32]; |
| 602 | |
| 603 | FreeHeader* free_header = alloc->is_free() ? |
| 604 | reinterpret_cast<FreeHeader*>(alloc) : NULL; |
| 605 | if (free_header) { |
| 606 | FreeMap::const_iterator found; |
| 607 | found = free_map.find(free_header->smaller_free(pool.pool_ptr_)); |
| 608 | if (found != free_map.end()) { |
| 609 | smlr_index = found->second; |
| 610 | snprintf(smlr_buff, 32, "[%2d]", smlr_index); // preprocessed out |
| 611 | } |
| 612 | found = free_map.find(free_header->larger_free(pool.pool_ptr_)); |
| 613 | if (found != free_map.end()) { |
| 614 | lrgr_index = found->second; |
| 615 | snprintf(lrgr_buff, 32, "[%2d]", lrgr_index); // preprocessed out |
| 616 | } |
| 617 | } |
| 618 | ACE_OS::printf( |
| 619 | "Alloc[%zu] %s at %zx ptr %zx lg %s sm %s size %d psize %d\n", |
nothing calls this directly
no test coverage detected