#include #include #include void mt_delete_shadow_lookup_tree_of_registry(MtShadowRegistry *registry); MtShadowRegistry mt_create_shadow_registry(void *context_ptr) { MtShadowRegistry registry; registry.id_counter = 1; registry.context_ptr = context_ptr; registry.lookup_tree = mt_create_shadow_lookup_tree(); mt_init_shadow_pool(®istry.root_pool, 16384); return registry; } void mt_cleanup_shadow_registry(MtShadowRegistry *registry) { mt_delete_shadow_lookup_tree_of_registry(registry); mt_cleanup_shadow_pool(®istry->root_pool); } void mt_cleanup_shadow_data(MtShadow *shadow) { if(shadow->tag_chain_start != NULL) mt_free_shadow_tag_chain(shadow->tag_chain_start); } void mt_delete_shadow_lookup_tree_of_registry(MtShadowRegistry *registry) { MtShadowLookupTree *lookup_tree = ®istry->lookup_tree; u32_t index_1 = 0; while(index_1 < 256) { MtShadowLookupLevel1 *level_1 = lookup_tree->next[index_1]; if(level_1 == NULL) { ++index_1; continue; } u32_t index_2 = 0; while(index_2 < 256) { MtShadowLookupLevel2 *level_2 = level_1->next[index_2]; if(level_2 == NULL) { ++index_2; continue; } u32_t index_3 = 0; while(index_3 < 256) { MtShadowLookupLevel3 *level_3 = level_2->next[index_3]; if(level_3 == NULL) { ++index_3; continue; } u32_t index_4 = 0; while(index_4 < 256) { MtShadow *shadow = level_3->next[index_4]; if(shadow == NULL) { ++index_4; continue; } mt_cleanup_shadow_data(shadow); ++index_4; } free(level_3); ++index_3; } free(level_2); ++index_2; } free(level_1); ++index_1; } }