mirror of
https://github.com/moparisthebest/curl
synced 2025-01-11 05:58:01 -05:00
llist: removed unused Curl_llist_move()
(and the corresponding unit test) Closes #4842
This commit is contained in:
parent
7745000338
commit
c0d7b05c41
53
lib/llist.c
53
lib/llist.c
@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -144,54 +144,3 @@ Curl_llist_count(struct curl_llist *list)
|
|||||||
{
|
{
|
||||||
return list->size;
|
return list->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @unittest: 1300
|
|
||||||
*/
|
|
||||||
void Curl_llist_move(struct curl_llist *list, struct curl_llist_element *e,
|
|
||||||
struct curl_llist *to_list,
|
|
||||||
struct curl_llist_element *to_e)
|
|
||||||
{
|
|
||||||
/* Remove element from list */
|
|
||||||
if(e == NULL || list->size == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(e == list->head) {
|
|
||||||
list->head = e->next;
|
|
||||||
|
|
||||||
if(list->head == NULL)
|
|
||||||
list->tail = NULL;
|
|
||||||
else
|
|
||||||
e->next->prev = NULL;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
e->prev->next = e->next;
|
|
||||||
if(!e->next)
|
|
||||||
list->tail = e->prev;
|
|
||||||
else
|
|
||||||
e->next->prev = e->prev;
|
|
||||||
}
|
|
||||||
|
|
||||||
--list->size;
|
|
||||||
|
|
||||||
/* Add element to to_list after to_e */
|
|
||||||
if(to_list->size == 0) {
|
|
||||||
to_list->head = e;
|
|
||||||
to_list->head->prev = NULL;
|
|
||||||
to_list->head->next = NULL;
|
|
||||||
to_list->tail = e;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
e->next = to_e->next;
|
|
||||||
e->prev = to_e;
|
|
||||||
if(to_e->next) {
|
|
||||||
to_e->next->prev = e;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
to_list->tail = e;
|
|
||||||
}
|
|
||||||
to_e->next = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
++to_list->size;
|
|
||||||
}
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -47,7 +47,4 @@ void Curl_llist_remove(struct curl_llist *, struct curl_llist_element *,
|
|||||||
void *);
|
void *);
|
||||||
size_t Curl_llist_count(struct curl_llist *);
|
size_t Curl_llist_count(struct curl_llist *);
|
||||||
void Curl_llist_destroy(struct curl_llist *, void *);
|
void Curl_llist_destroy(struct curl_llist *, void *);
|
||||||
void Curl_llist_move(struct curl_llist *, struct curl_llist_element *,
|
|
||||||
struct curl_llist *, struct curl_llist_element *);
|
|
||||||
|
|
||||||
#endif /* HEADER_CURL_LLIST_H */
|
#endif /* HEADER_CURL_LLIST_H */
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -54,7 +54,6 @@ UNITTEST_START
|
|||||||
struct curl_llist_element case2_list;
|
struct curl_llist_element case2_list;
|
||||||
struct curl_llist_element case3_list;
|
struct curl_llist_element case3_list;
|
||||||
struct curl_llist_element case4_list;
|
struct curl_llist_element case4_list;
|
||||||
struct curl_llist_element case5_list;
|
|
||||||
struct curl_llist_element *head;
|
struct curl_llist_element *head;
|
||||||
struct curl_llist_element *element_next;
|
struct curl_llist_element *element_next;
|
||||||
struct curl_llist_element *element_prev;
|
struct curl_llist_element *element_prev;
|
||||||
@ -216,55 +215,6 @@ UNITTEST_START
|
|||||||
fail_unless(llist.tail == NULL,
|
fail_unless(llist.tail == NULL,
|
||||||
"llist tail is not NULL while the llist is empty");
|
"llist tail is not NULL while the llist is empty");
|
||||||
|
|
||||||
/* @testing Curl_llist_move(struct curl_llist *,
|
|
||||||
* struct curl_llist_element *, struct curl_llist *,
|
|
||||||
* struct curl_llist_element *);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @case 1:
|
|
||||||
* moving head from an llist containing one element to an empty llist
|
|
||||||
* @assumptions:
|
|
||||||
* 1: llist size will be 0
|
|
||||||
* 2: llist_destination size will be 1
|
|
||||||
* 3: llist head will be NULL
|
|
||||||
* 4: llist_destination head == llist_destination tail != NULL
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @setup
|
|
||||||
* add one element to the list
|
|
||||||
*/
|
|
||||||
|
|
||||||
Curl_llist_insert_next(&llist, llist.head, &unusedData_case1,
|
|
||||||
&case5_list);
|
|
||||||
/* necessary assertions */
|
|
||||||
|
|
||||||
abort_unless(Curl_llist_count(&llist) == 1,
|
|
||||||
"Number of list elements is not as expected, Aborting");
|
|
||||||
abort_unless(Curl_llist_count(&llist_destination) == 0,
|
|
||||||
"Number of list elements is not as expected, Aborting");
|
|
||||||
|
|
||||||
/*actual testing code*/
|
|
||||||
Curl_llist_move(&llist, llist.head, &llist_destination, NULL);
|
|
||||||
fail_unless(Curl_llist_count(&llist) == 0,
|
|
||||||
"moving element from llist didn't decrement the size");
|
|
||||||
|
|
||||||
fail_unless(Curl_llist_count(&llist_destination) == 1,
|
|
||||||
"moving element to llist_destination didn't increment the size");
|
|
||||||
|
|
||||||
fail_unless(llist.head == NULL,
|
|
||||||
"llist head not set to null after moving the head");
|
|
||||||
|
|
||||||
fail_unless(llist_destination.head != NULL,
|
|
||||||
"llist_destination head set to null after moving an element");
|
|
||||||
|
|
||||||
fail_unless(llist_destination.tail != NULL,
|
|
||||||
"llist_destination tail set to null after moving an element");
|
|
||||||
|
|
||||||
fail_unless(llist_destination.tail == llist_destination.head,
|
|
||||||
"llist_destination tail doesn't equal llist_destination head");
|
|
||||||
|
|
||||||
Curl_llist_destroy(&llist, NULL);
|
Curl_llist_destroy(&llist, NULL);
|
||||||
Curl_llist_destroy(&llist_destination, NULL);
|
Curl_llist_destroy(&llist_destination, NULL);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user