frees memory for bitmap object.
| 773 | |
| 774 | // frees memory for bitmap object. |
| 775 | void newuiResources::Free(UIBitmapItem *bmitem) { |
| 776 | int i; |
| 777 | |
| 778 | if (!bmitem) { |
| 779 | Int3(); // Get samir. |
| 780 | return; |
| 781 | } |
| 782 | |
| 783 | for (i = 0; i < N_NEWUI_BMPS_TOTAL; i++) { |
| 784 | if (m_list[i].n_count > 0) { |
| 785 | if (m_list[i].chunked && bmitem->is_chunked()) { |
| 786 | if (bmitem->get_chunked_bitmap()->bm_array == m_list[i].chunk.bm_array) { |
| 787 | break; |
| 788 | } |
| 789 | } else if (!m_list[i].chunked && !bmitem->is_chunked()) { |
| 790 | if (bmitem->get_bitmap() == m_list[i].bm_handle) { |
| 791 | break; |
| 792 | } |
| 793 | } |
| 794 | } |
| 795 | } |
| 796 | |
| 797 | if (i >= N_NEWUI_BMPS_TOTAL) { |
| 798 | Int3(); // maybe we should free this, well this really should never happen but if it does |
| 799 | return; // I can't be completely sure this is a valid pointer, so rather than risking a crash I'll have a leak. |
| 800 | } |
| 801 | |
| 802 | // ASSERT(i < N_NEWUI_BMPS_TOTAL); |
| 803 | |
| 804 | // decrement and free. |
| 805 | delete bmitem; |
| 806 | |
| 807 | m_list[i].n_count--; |
| 808 | if (m_list[i].n_count == 0) { |
| 809 | if (m_list[i].chunked) { |
| 810 | bm_DestroyChunkedBitmap(&m_list[i].chunk); |
| 811 | } else { |
| 812 | bm_FreeBitmap(m_list[i].bm_handle); |
| 813 | } |
| 814 | mem_free(m_list[i].filename); |
| 815 | } |
| 816 | } |
| 817 | |
| 818 | ////////////////////////////////////////////////////////////////////////////// |
| 819 | // CLASS a menu with options and sheets |
no test coverage detected