Ejemplo n.º 1
0
/* =============================================================================
 * allocNode
 * =============================================================================
 */
static net_node_t*
allocNode (long id)
{
    net_node_t* nodePtr;

    nodePtr = (net_node_t*)SEQ_MALLOC(sizeof(net_node_t));
    if (nodePtr) {
        nodePtr->parentIdListPtr = Plist_alloc(&net_compareid);
        if (nodePtr->parentIdListPtr == NULL) {
            SEQ_FREE(nodePtr);
            return NULL;
        }
        nodePtr->childIdListPtr = Plist_alloc(&net_compareid);
        if (nodePtr->childIdListPtr == NULL) {
            list_free(nodePtr->parentIdListPtr);
            SEQ_FREE(nodePtr);
            return NULL;
        }
        nodePtr->id = id;
    }

    return nodePtr;
}
Ejemplo n.º 2
0
customer_t*
customer_alloc_seq (long id)
{
    customer_t* customerPtr;

    customerPtr = (customer_t*)SEQ_MALLOC(sizeof(customer_t));
    assert(customerPtr != NULL);

    customerPtr->id = id;

    customerPtr->reservationInfoListPtr = Plist_alloc(&customer_comparereservationinfo);
    assert(customerPtr->reservationInfoListPtr != NULL);

    return customerPtr;
}
Ejemplo n.º 3
0
/* =============================================================================
 * element_alloc
 *
 * Contains a copy of input arg 'coordinates'
 * =============================================================================
 */
element_t*
element_alloc (coordinate_t* coordinates, long numCoordinate)
{
    element_t* elementPtr;

    elementPtr = (element_t*)SEQ_MALLOC(sizeof(element_t));
    if (elementPtr) {
        long i;
        for (i = 0; i < numCoordinate; i++) {
            elementPtr->coordinates[i] = coordinates[i];
        }
        elementPtr->numCoordinate = numCoordinate;
        minimizeCoordinates(elementPtr);
        checkAngles(elementPtr);
        calculateCircumCircle(elementPtr);
        initEdges(elementPtr, coordinates, numCoordinate);
        elementPtr->neighborListPtr = Plist_alloc(&element_listcompare);
        assert(elementPtr->neighborListPtr);
        elementPtr->isGarbage = false;
        elementPtr->isReferenced = false;
    }

    return elementPtr;
}