static KidsHash *
HashChildren(Shape *kid1, Shape *kid2)
{
    KidsHash *hash = js_new<KidsHash>();
    if (!hash || !hash->init(2)) {
        js_delete(hash);
        return nullptr;
    }

    JS_ALWAYS_TRUE(hash->putNew(StackShape(kid1), kid1));
    JS_ALWAYS_TRUE(hash->putNew(StackShape(kid2), kid2));
    return hash;
}
static KidsHash *
HashChildren(UnrootedShape kid1, UnrootedShape kid2)
{
    KidsHash *hash = js_new<KidsHash>();
    if (!hash || !hash->init(2)) {
        js_delete(hash);
        return NULL;
    }

    JS_ALWAYS_TRUE(hash->putNew(kid1, kid1));
    JS_ALWAYS_TRUE(hash->putNew(kid2, kid2));
    return hash;
}
예제 #3
0
static KidsHash*
HashChildren(Shape* kid1, Shape* kid2)
{
    KidsHash* hash = js_new<KidsHash>();
    if (!hash || !hash->init(2)) {
        js_delete(hash);
        return nullptr;
    }

    hash->putNewInfallible(StackShape(kid1), kid1);
    hash->putNewInfallible(StackShape(kid2), kid2);
    return hash;
}
예제 #4
0
static KidsHash *
HashChildren(Shape *kid1, Shape *kid2)
{
    void *mem = js_malloc(sizeof(KidsHash));
    if (!mem)
        return NULL;

    KidsHash *hash = new (mem) KidsHash();
    if (!hash->init(2)) {
        js_free(hash);
        return NULL;
    }

    KidsHash::AddPtr addPtr = hash->lookupForAdd(kid1);
    JS_ALWAYS_TRUE(hash->add(addPtr, kid1));

    addPtr = hash->lookupForAdd(kid2);
    JS_ASSERT(!addPtr.found());
    JS_ALWAYS_TRUE(hash->add(addPtr, kid2));

    return hash;
}