8000 javascriptlint/spidermonkey/src/jsatom.c at patch-1 · mcavage/javascriptlint · GitHub
Skip to content

Latest commit

 

History

History
999 lines (886 loc) · 28.4 KB

File metadata and controls

999 lines (886 loc) · 28.4 KB
return HT_ENUMERATE_NEXT;
}
#ifdef DEBUG
static jsrefcount js_atom_map_count;
static jsrefcount js_atom_map_hash_table_count;
#endif
JS_FRIEND_API(JSBool)
js_InitAtomMap(JSContext *cx, JSAtomMap *map, JSAtomList *al)
{
JSAtom **vector;
JSAtomListElement *ale;
uint32 count;
#ifdef DEBUG
JS_ATOMIC_INCREMENT(&js_atom_map_count);
#endif
ale = al->list;
if (!ale && !al->table) {
map->vector = NULL;
map->length = 0;
return JS_TRUE;
}
count = al->count;
if (count >= ATOM_INDEX_LIMIT) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
JSMSG_TOO_MANY_LITERALS);
return JS_FALSE;
}
vector = (JSAtom **) JS_malloc(cx, (size_t) count * sizeof *vector);
if (!vector)
return JS_FALSE;
if (al->table) {
#ifdef DEBUG
JS_ATOMIC_INCREMENT(&js_atom_map_hash_table_count);
#endif
JS_HashTableEnumerateEntries(al->table, js_map_atom, vector);
} else {
do {
vector[ALE_INDEX(ale)] = ALE_ATOM(ale);
} while ((ale = ALE_NEXT(ale)) != NULL);
}
ATOM_LIST_INIT(al);
map->vector = vector;
map->length = (jsatomid)count;
return JS_TRUE;
}
JS_FRIEND_API(void)
js_FreeAtomMap(JSContext *cx, JSAtomMap *map)
{
if (map->vector) {
JS_free(cx, map->vector);
map->vector = NULL;
}
map->length = 0;
}