| 1088 | } |
| 1089 | |
| 1090 | void close_lua_state(lua_State *L) { |
| 1091 | luaL_commit_storage_changes(L); |
| 1092 | thinkyoung::lua::api::global_glua_chain_api->release_objects_in_pool(L); |
| 1093 | LStatesMap *states_map = get_lua_states_value_hashmap(); |
| 1094 | |
| 1095 | if (nullptr != states_map) { |
| 1096 | auto lua_table_map_list_p = get_lua_state_value(L, LUA_TABLE_MAP_LIST_STATE_MAP_KEY).pointer_value; |
| 1097 | |
| 1098 | if (nullptr != lua_table_map_list_p) { |
| 1099 | auto list_p = (std::list<GluaTableMapP>*) lua_table_map_list_p; |
| 1100 | |
| 1101 | for (auto it = list_p->begin(); it != list_p->end(); ++it) { |
| 1102 | GluaTableMapP lua_table_map = *it; |
| 1103 | // lua_table_map->~GluaTableMap(); |
| 1104 | // lua_free(L, lua_table_map); |
| 1105 | delete lua_table_map; |
| 1106 | } |
| 1107 | |
| 1108 | delete list_p; |
| 1109 | } |
| 1110 | |
| 1111 | L_V1 map = create_value_map_for_lua_state(L); |
| 1112 | |
| 1113 | for (auto it = map->begin(); it != map->end(); ++it) { |
| 1114 | if (it->second.type == LUA_STATE_VALUE_INT_POINTER) { |
| 1115 | lua_free(L, it->second.value.int_pointer_value); |
| 1116 | it->second.value.int_pointer_value = nullptr; |
| 1117 | } |
| 1118 | } |
| 1119 | |
| 1120 | // close values in state values(some pointers need free), eg. storage infos, contract infos |
| 1121 | GluaStateValueNode storage_changelist_node = get_lua_state_value_node(L, LUA_STORAGE_CHANGELIST_KEY); |
| 1122 | |
| 1123 | if (storage_changelist_node.type == LUA_STATE_VALUE_POINTER && nullptr != storage_changelist_node.value.pointer_value) { |
| 1124 | GluaStorageChangeList *list = (GluaStorageChangeList*)storage_changelist_node.value.pointer_value; |
| 1125 | |
| 1126 | for (auto it = list->begin(); it != list->end(); ++it) { |
| 1127 | GluaStorageValue before = it->before; |
| 1128 | GluaStorageValue after = it->after; |
| 1129 | |
| 1130 | if (lua_storage_is_table(before.type)) { |
| 1131 | // free_lua_table_map(L, before.value.table_value); |
| 1132 | } |
| 1133 | |
| 1134 | if (lua_storage_is_table(after.type)) { |
| 1135 | // free_lua_table_map(L, after.value.table_value); |
| 1136 | } |
| 1137 | } |
| 1138 | |
| 1139 | list->~GluaStorageChangeList(); |
| 1140 | lua_free(L, list); |
| 1141 | } |
| 1142 | |
| 1143 | GluaStateValueNode storage_table_read_list_node = get_lua_state_value_node(L, LUA_STORAGE_READ_TABLES_KEY); |
| 1144 | |
| 1145 | if (storage_table_read_list_node.type == LUA_STATE_VALUE_POINTER && nullptr != storage_table_read_list_node.value.pointer_value) { |
| 1146 | GluaStorageTableReadList *list = (GluaStorageTableReadList*)storage_table_read_list_node.value.pointer_value; |
| 1147 | list->~GluaStorageTableReadList(); |
no test coverage detected