Release all blocks of the storage (or return them to parent, if any): */
| 123 | |
| 124 | /* Release all blocks of the storage (or return them to parent, if any): */ |
| 125 | static void |
| 126 | icvDestroyMemStorage( CvMemStorage* storage ) |
| 127 | { |
| 128 | int k = 0; |
| 129 | |
| 130 | CvMemBlock *block; |
| 131 | CvMemBlock *dst_top = 0; |
| 132 | |
| 133 | if( !storage ) |
| 134 | CV_Error( CV_StsNullPtr, "" ); |
| 135 | |
| 136 | if( storage->parent ) |
| 137 | dst_top = storage->parent->top; |
| 138 | |
| 139 | for( block = storage->bottom; block != 0; k++ ) |
| 140 | { |
| 141 | CvMemBlock *temp = block; |
| 142 | |
| 143 | block = block->next; |
| 144 | if( storage->parent ) |
| 145 | { |
| 146 | if( dst_top ) |
| 147 | { |
| 148 | temp->prev = dst_top; |
| 149 | temp->next = dst_top->next; |
| 150 | if( temp->next ) |
| 151 | temp->next->prev = temp; |
| 152 | dst_top = dst_top->next = temp; |
| 153 | } |
| 154 | else |
| 155 | { |
| 156 | dst_top = storage->parent->bottom = storage->parent->top = temp; |
| 157 | temp->prev = temp->next = 0; |
| 158 | storage->free_space = storage->block_size - sizeof( *temp ); |
| 159 | } |
| 160 | } |
| 161 | else |
| 162 | { |
| 163 | cvFree( &temp ); |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | storage->top = storage->bottom = 0; |
| 168 | storage->free_space = 0; |
| 169 | } |
| 170 | |
| 171 | |
| 172 | /* Release memory storage: */ |
no outgoing calls
no test coverage detected