/* * Remove the mapping of a JS object from the hash table that maps JS objects * to Java objects. This is called from the finalizer of an instance of * netscape.javascript.JSObject. */ JSBool jsj_remove_js_obj_reflection_from_hashtable(JSContext *cx, JSObject *js_obj) { JSHashEntry *he, **hep; JSBool success = JS_FALSE; #ifdef JSJ_THREADSAFE PR_EnterMonitor(js_obj_reflections_monitor); #endif /* Get the hash-table entry for this wrapper object */ hep = JS_HashTableRawLookup(js_obj_reflections, (JSHashNumber)js_obj, js_obj); he = *hep; JS_ASSERT(he); if (he) { /* Tell the JS GC that Java no longer keeps a reference to this JS object. */ success = JS_RemoveRoot(cx, (void *)&he->key); JS_HashTableRawRemove(js_obj_reflections, hep, he); } #ifdef JSJ_THREADSAFE PR_ExitMonitor(js_obj_reflections_monitor); #endif return success; }
JS_HashTableRemove(JSHashTable *ht, const void *key) { JSHashNumber keyHash; JSHashEntry *he, **hep; keyHash = ht->keyHash(key); hep = JS_HashTableRawLookup(ht, keyHash, key); if ((he = *hep) == NULL) return JS_FALSE; /* Hit; remove element */ JS_HashTableRawRemove(ht, hep, he); return JS_TRUE; }
void JSAtomList::rawRemove(JSCompiler *jsc, JSAtomListElement *ale, JSHashEntry **hep) { JS_ASSERT(!set); JS_ASSERT(count != 0); if (table) { JS_ASSERT(hep); JS_HashTableRawRemove(table, hep, &ale->entry); } else { JS_ASSERT(!hep); hep = &list; while (*hep != &ale->entry) { JS_ASSERT(*hep); hep = &(*hep)->next; } *hep = ale->entry.next; js_free_temp_entry(jsc, &ale->entry, HT_FREE_ENTRY); } --count; }