MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / Free

Method Free

Descent3/newui_core.cpp:775–816  ·  view source on GitHub ↗

frees memory for bitmap object.

Source from the content-addressed store, hash-verified

773
774// frees memory for bitmap object.
775void 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

Callers 3

DoBrowseMethod · 0.80
newui_FreeBitmapFunction · 0.80
OnDestroyMethod · 0.80

Calls 5

bm_DestroyChunkedBitmapFunction · 0.85
bm_FreeBitmapFunction · 0.85
is_chunkedMethod · 0.80
get_chunked_bitmapMethod · 0.80
get_bitmapMethod · 0.80

Tested by

no test coverage detected