Пример #1
0
void flower_destruct(Flower *flower, int64_t recursive) {
    Flower_GroupIterator *iterator;
    Sequence *sequence;
    End *end;
    Block *block;
    Group *group;
    Chain *chain;
    Flower *nestedFlower;

    if (recursive) {
        iterator = flower_getGroupIterator(flower);
        while ((group = flower_getNextGroup(iterator)) != NULL) {
            nestedFlower = group_getNestedFlower(group);
            if (nestedFlower != NULL) {
                flower_destruct(nestedFlower, recursive);
            }
        }
        flower_destructGroupIterator(iterator);
    }

    cactusDisk_removeFlower(flower->cactusDisk, flower);

    flower_destructFaces(flower);
    stSortedSet_destruct(flower->faces);

    assert(flower_getEventTree(flower) != NULL);
    eventTree_destruct(flower_getEventTree(flower));

    while ((sequence = flower_getFirstSequence(flower)) != NULL) {
        sequence_destruct(sequence);
    }
    stSortedSet_destruct(flower->sequences);

    while ((chain = flower_getFirstChain(flower)) != NULL) {
        chain_destruct(chain);
    }
    stSortedSet_destruct(flower->chains);

    while ((end = flower_getFirstEnd(flower)) != NULL) {
        end_destruct(end);
    }
    stSortedSet_destruct(flower->caps);
    stSortedSet_destruct(flower->ends);

    while ((block = flower_getFirstBlock(flower)) != NULL) {
        block_destruct(block);
    }
    stSortedSet_destruct(flower->segments);
    stSortedSet_destruct(flower->blocks);

    while ((group = flower_getFirstGroup(flower)) != NULL) {
        group_destruct(group);
    }
    stSortedSet_destruct(flower->groups);

    free(flower);
}
Пример #2
0
void testEnd_serialisation(CuTest* testCase) {
    cactusEndTestSetup();
    Name rootInstanceName = cap_getName(rootCap);
    Name leaf1InstanceName = cap_getName(leaf1Cap);
    Name leaf2InstanceName = cap_getName(leaf2Cap);
    Name leaf3InstanceName = cap_getName(leaf3Cap);
    int64_t i;
    void *vA = binaryRepresentation_makeBinaryRepresentation(end,
            (void(*)(void *, void(*)(const void *, size_t, size_t))) end_writeBinaryRepresentation, &i);
    CuAssertTrue(testCase, i > 0);
    end_destruct(end);
    void *vA2 = vA;
    end = end_loadFromBinaryRepresentation(&vA2, flower);
    rootCap = cap_getReverse(end_getInstance(end, rootInstanceName));
    leaf1Cap = cap_getReverse(end_getInstance(end, leaf1InstanceName));
    leaf2Cap = end_getInstance(end, leaf2InstanceName);
    leaf3Cap = cap_getReverse(end_getInstance(end, leaf3InstanceName));
    CuAssertTrue(testCase, leaf3Cap != NULL);
    free(vA);
    nestedTest = 1;
    testEnd_copyConstruct(testCase);
    testEnd_getName(testCase);
    testEnd_getOrientation(testCase);
    testEnd_getReverse(testCase);
    testEnd_getSide(testCase);
    testEnd_getFlower(testCase);
    testEnd_getBlock(testCase);
    testEnd_getOtherBlockEnd(testCase);
    testEnd_getGroup(testCase);
    testEnd_setGroup(testCase);
    testEnd_getInstanceNumber(testCase);
    testEnd_getInstance(testCase);
    testEnd_getFirst(testCase);
    testEnd_getSetRootInstance(testCase);
    testEnd_instanceIterator(testCase);
    testEnd_isBlockOrStubEnd(testCase);
    testEnd_isAttachedOrFree(testCase);
    testEnd_getCapForEvent(testCase);
    nestedTest = 0;
    cactusEndTestTeardown();
}