Beispiel #1
0
TEST_C(DequeTests, DequeRemoveAll)
{
    int a = 1;
    int b = 2;
    int c = 3;

    deque_add(deque, &a);
    deque_add(deque, &b);
    deque_add(deque, &c);

    deque_remove_all(deque);

    void *first;
    int stat1 = deque_get_first(deque, &first);
    void *last;
    int stat2 = deque_get_last(deque, &last);

    CHECK_EQUAL_C_INT(CC_ERR_OUT_OF_RANGE, stat1);
    CHECK_EQUAL_C_INT(CC_ERR_OUT_OF_RANGE, stat2);

    CHECK_EQUAL_C_INT(0, deque_size(deque));
};
Beispiel #2
0
/**
 * Removes and frees all element from the specified Deque.
 *
 * @note This function does not shrink the Deque's capacity.
 * @note This function should not be called on Deques that have some
 *       of their elements allocated on stack.
 *
 * @param[in] deque Deque from which all elements are being removed
 */
void deque_remove_all_free(Deque *deque)
{
    deque_foreach(deque, deque->mem_free);
    deque_remove_all(deque);
}