Exemple #1
0
/* =============================================================================
 * TMhashtable_remove
 * -- Returns TRUE if successful, else FALSE
 * =============================================================================
 */
bool_t
TMhashtable_remove (TM_ARGDECL  hashtable_t* hashtablePtr, void* keyPtr)
{
    long numBucket = hashtablePtr->numBucket;
    long i = hashtablePtr->hash(keyPtr) % numBucket;
    list_t* chainPtr = hashtablePtr->buckets[i];
    pair_t* pairPtr;
    pair_t removePair;

    removePair.firstPtr = keyPtr;
    pairPtr = (pair_t*)TMLIST_FIND(chainPtr, &removePair);
    if (pairPtr == NULL) {
        return FALSE;
    }

    bool_t status = TMLIST_REMOVE(chainPtr, &removePair);
    assert(status);
    TMPAIR_FREE(pairPtr);

#ifdef HASHTABLE_SIZE_FIELD
    TM_SHARED_WRITE(hashtablePtr->size
                    (long)TM_SHARED_READ(hashtablePtr->size)-1);
    assert(hashtablePtr->size >= 0);
#endif

    return TRUE;
}
Exemple #2
0
/* =============================================================================
 * TMremoveEdge
 * =============================================================================
 */
static void
TMremoveEdge (TM_ARGDECL  net_t* netPtr, long fromId, long toId)
{
    vector_t* nodeVectorPtr = netPtr->nodeVectorPtr;
    bool_t status;

    net_node_t* childNodePtr = (net_node_t*)vector_at(nodeVectorPtr, toId);
    list_t* parentIdListPtr = childNodePtr->parentIdListPtr;
    status = TMLIST_REMOVE(parentIdListPtr, (void*)fromId);
    assert(status);

    net_node_t* parentNodePtr = (net_node_t*)vector_at(nodeVectorPtr, fromId);
    list_t* childIdListPtr = parentNodePtr->childIdListPtr;
    status = TMLIST_REMOVE(childIdListPtr, (void*)toId);
    assert(status);
}
Exemple #3
0
static void
TMremoveEdge (al_t* lock, net_t* netPtr, long fromId, long toId)
{
    vector_t* nodeVectorPtr = LocalLoad(&netPtr->nodeVectorPtr);
    bool_t status;

    net_node_t* childNodePtr = (net_node_t*)vector_at(nodeVectorPtr, toId);
    list_t* parentIdListPtr = LocalLoad(&childNodePtr->parentIdListPtr);
    status = TMLIST_REMOVE(lock, parentIdListPtr, (void*)fromId);
    assert(status);

    net_node_t* parentNodePtr = (net_node_t*)vector_at(nodeVectorPtr, fromId);
    list_t* childIdListPtr = LocalLoad(&parentNodePtr->childIdListPtr);
    status = TMLIST_REMOVE(lock, childIdListPtr, (void*)toId);
    assert(status);
}
Exemple #4
0
/* =============================================================================
 * customer_removeReservationInfo
 * -- Returns TRUE if success, else FALSE
 * =============================================================================
 */
bool_t
customer_removeReservationInfo (TM_ARGDECL
                                customer_t* customerPtr,
                                reservation_type_t type, long id)
{
    reservation_info_t findReservationInfo;

    findReservationInfo.type = type;
    findReservationInfo.id = id;
    /* price not used to compare reservation infos */

    list_t* reservationInfoListPtr =
        (list_t*)TM_SHARED_READ_P(customerPtr->reservationInfoListPtr);

    reservation_info_t* reservationInfoPtr =
        (reservation_info_t*)TMLIST_FIND(reservationInfoListPtr,
                                         &findReservationInfo);

    if (reservationInfoPtr == NULL) {
        return FALSE;
    }

    bool_t status = TMLIST_REMOVE(reservationInfoListPtr,
                                  (void*)&findReservationInfo);
    if (status == FALSE) {
        TM_RESTART();
    }

    RESERVATION_INFO_FREE(reservationInfoPtr);

    return TRUE;
}
Exemple #5
0
/* =============================================================================
 * customer_removeReservationInfo
 * -- Returns TRUE if success, else FALSE
 * =============================================================================
 */
__attribute__((transaction_safe)) bool_t
customer_removeReservationInfo (
                                customer_t* customerPtr,
                                reservation_type_t type, long id)
{
    reservation_info_t findReservationInfo;

    findReservationInfo.type = type;
    findReservationInfo.id = id;
    /* price not used to compare reservation infos */

    list_t* reservationInfoListPtr = customerPtr->reservationInfoListPtr;

    reservation_info_t* reservationInfoPtr =
        (reservation_info_t*)TMLIST_FIND(reservationInfoListPtr,
                                         &findReservationInfo);

    if (reservationInfoPtr == NULL) {
        return FALSE;
    }

    TMLIST_REMOVE(reservationInfoListPtr,(void*)&findReservationInfo);
    RESERVATION_INFO_FREE(reservationInfoPtr);

    return TRUE;
}