Fixing restart of context to not leak memory

This commit is contained in:
Rohan Kuruvilla 2012-10-11 18:05:25 -07:00
parent e7ac758b9f
commit eafd6ebf08
2 changed files with 7 additions and 2 deletions

View File

@ -372,6 +372,12 @@ void ScriptingCore::removeAllRoots(JSContext *cx) {
js_proxy_t *current, *tmp;
HASH_ITER(hh, _js_native_global_ht, current, tmp) {
JS_RemoveObjectRoot(cx, &current->obj);
HASH_DEL(_js_native_global_ht, current);
free(current);
}
HASH_ITER(hh, _native_js_global_ht, current, tmp) {
HASH_DEL(_native_js_global_ht, current);
free(current);
}
HASH_CLEAR(hh, _js_native_global_ht);
HASH_CLEAR(hh, _native_js_global_ht);

View File

@ -12,8 +12,7 @@
template <class T>
inline js_type_class_t *js_get_type_from_native(T* native_obj) {
js_type_class_t *typeProxy;
const char *n = typeid(*native_obj).name();
long typeId = getHashCodeByString(n);
long typeId = getHashCodeByString(typeid(*native_obj).name());
HASH_FIND_INT(_js_global_type_ht, &typeId, typeProxy);
if (!typeProxy) {
TypeInfo *typeInfo = dynamic_cast<TypeInfo *>(native_obj);