Changeset 350 for trunk/nv/core/handle.hh
- Timestamp:
- 02/04/15 16:37:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/core/handle.hh
r347 r350 84 84 value_type i = get_free_entry(); 85 85 m_entries[i].counter++; 86 NV_ASSERT( m_entries[i].counter != 0, "Out of handles!" ); 86 87 m_entries[i].next_free = USED; 87 88 return hop::create( i, m_entries[i].counter ); … … 90 91 void free_handle( handle h ) 91 92 { 92 m_entries[h.index()].next_free = NONE; 93 if ( m_last_free == -1 ) 93 value_type index = h.index(); 94 typedef handle_operator<HANDLE> hop; 95 NV_ASSERT( m_entries[index].next_free == USED, "Unused handle freed!" ); 96 NV_ASSERT( m_entries[index].counter == hop::get_counter( h ), "Handle corruption!" ); 97 m_entries[index].next_free = NONE; 98 if ( m_last_free == NONE ) 94 99 { 95 m_first_free = m_last_free = h.index();100 m_first_free = m_last_free = index; 96 101 return; 97 102 } 98 m_entries[(unsigned)m_last_free].next_free = h.index();99 m_last_free = h.index();103 m_entries[(unsigned)m_last_free].next_free = index; 104 m_last_free = index; 100 105 } 101 106 … … 120 125 value_type get_free_entry() 121 126 { 122 if ( m_first_free != -1)127 if ( m_first_free != NONE ) 123 128 { 124 129 value_type result = (value_type)m_first_free; 125 130 m_first_free = m_entries[result].next_free; 126 131 m_entries[result].next_free = USED; 127 if ( m_first_free == -1 ) m_last_free = -1;132 if ( m_first_free == NONE ) m_last_free = NONE; 128 133 return result; 129 134 }
Note: See TracChangeset
for help on using the changeset viewer.