as->expires = expires;
as->prio = prio;
as->persist = persist ? 1 : 0;
- Curl_llist_insert_next(&asi->list, asi->list.tail, as, &as->node);
+ Curl_llist_append(&asi->list, as, &as->node);
}
}
account. [See RFC 7838 section 3.1] */
as->expires = maxage + time(NULL);
as->persist = persist;
- Curl_llist_insert_next(&asi->list, asi->list.tail, as, &as->node);
+ Curl_llist_append(&asi->list, as, &as->node);
infof(data, "Added alt-svc: %s:%d over %s", dsthost, dstport,
Curl_alpnid2str(dstalpnid));
}
static void bundle_add_conn(struct connectbundle *bundle,
struct connectdata *conn)
{
- Curl_llist_insert_next(&bundle->conn_list, bundle->conn_list.tail, conn,
- &conn->bundle_node);
+ Curl_llist_append(&bundle->conn_list, conn, &conn->bundle_node);
conn->bundle = bundle;
bundle->num_connections++;
}
Curl_set_in_callback(data, false);
if(add) {
- Curl_llist_insert_next(llist, llist->tail, finfo, &infop->list);
+ Curl_llist_append(llist, finfo, &infop->list);
}
else {
Curl_fileinfo_cleanup(infop);
he = mk_hash_element(key, key_len, p);
if(he) {
- Curl_llist_insert_next(l, l->tail, he, &he->list);
+ Curl_llist_append(l, he, &he->list);
++h->size;
return p; /* return the new entry */
}
newhs->value[olen + vlen] = 0; /* null-terminate at newline */
/* insert this node into the list of headers */
- Curl_llist_insert_next(&data->state.httphdrs, data->state.httphdrs.tail,
- newhs, &newhs->node);
+ Curl_llist_append(&data->state.httphdrs, newhs, &newhs->node);
data->state.prevhead = newhs;
return CURLE_OK;
}
hs->request = data->state.requests;
/* insert this node into the list of headers */
- Curl_llist_insert_next(&data->state.httphdrs, data->state.httphdrs.tail,
- hs, &hs->node);
+ Curl_llist_append(&data->state.httphdrs, hs, &hs->node);
data->state.prevhead = hs;
}
else
sts->host = duphost;
sts->expires = expires;
sts->includeSubDomains = subdomains;
- Curl_llist_insert_next(&h->list, h->list.tail, sts, &sts->node);
+ Curl_llist_append(&h->list, sts, &sts->node);
}
return CURLE_OK;
}
++list->size;
}
+/*
+ * Curl_llist_append()
+ *
+ * Adds a new list element to the end of the list.
+ *
+ * The 'ne' argument should be a pointer into the object to store.
+ *
+ * @unittest: 1300
+ */
+void
+Curl_llist_append(struct Curl_llist *list, const void *p,
+ struct Curl_llist_element *ne)
+{
+ Curl_llist_insert_next(list, list->tail, p, ne);
+}
+
/*
* @unittest: 1300
*/
void Curl_llist_init(struct Curl_llist *, Curl_llist_dtor);
void Curl_llist_insert_next(struct Curl_llist *, struct Curl_llist_element *,
const void *, struct Curl_llist_element *node);
+void Curl_llist_append(struct Curl_llist *,
+ const void *, struct Curl_llist_element *node);
void Curl_llist_remove(struct Curl_llist *, struct Curl_llist_element *,
void *);
size_t Curl_llist_count(struct Curl_llist *);
*/
static void multi_addmsg(struct Curl_multi *multi, struct Curl_message *msg)
{
- Curl_llist_insert_next(&multi->msglist, multi->msglist.tail, msg,
- &msg->list);
+ Curl_llist_append(&multi->msglist, msg, &msg->list);
}
struct Curl_multi *Curl_multi_handle(int hashsize, /* socket hash */
DEBUGASSERT(!data->conn);
DEBUGASSERT(conn);
data->conn = conn;
- Curl_llist_insert_next(&conn->easyq, conn->easyq.tail, data,
- &data->conn_queue);
+ Curl_llist_append(&conn->easyq, data, &data->conn_queue);
if(conn->handler && conn->handler->attach)
conn->handler->attach(data, conn);
Curl_conn_ev_data_attach(conn, data);
multistate(data, MSTATE_PENDING);
/* add this handle to the list of connect-pending handles */
- Curl_llist_insert_next(&multi->pending, multi->pending.tail, data,
- &data->connect_queue);
+ Curl_llist_append(&multi->pending, data, &data->connect_queue);
/* unlink from the main list */
unlink_easy(multi, data);
result = CURLE_OK;
multistate(data, MSTATE_MSGSENT);
/* add this handle to the list of msgsent handles */
- Curl_llist_insert_next(&multi->msgsent, multi->msgsent.tail, data,
- &data->connect_queue);
+ Curl_llist_append(&multi->msgsent, data, &data->connect_queue);
/* unlink from the main list */
unlink_easy(multi, data);
return CURLM_OK;
BIT(dead); /* a callback returned error, everything needs to crash and
burn */
BIT(xfer_buf_borrowed); /* xfer_buf is currently being borrowed */
- BIT(xfer_ulbuf_borrowed); /* xfer_buf is currently being borrowed */
+ BIT(xfer_ulbuf_borrowed); /* xfer_ulbuf is currently being borrowed */
#ifdef DEBUGBUILD
BIT(warned); /* true after user warned of DEBUGBUILD */
#endif
fail_unless(llist.tail == NULL,
"llist tail is not NULL while the llist is empty");
+ /**
+ * testing Curl_llist_append
+ * case 1:
+ * list is empty
+ * @assumptions:
+ * 1: the element next to head should be our newly created element
+ * 2: the list tail should different from newly created element
+ */
+ Curl_llist_append(&llist, &unusedData_case1, &case1_list);
+ fail_unless(Curl_llist_count(&llist) == 1,
+ "List size should be 1 after appending a new element");
+ /* test that the list head data holds my unusedData */
+ fail_unless(llist.head->ptr == &unusedData_case1,
+ "head ptr should be first entry");
+ /* same goes for the list tail */
+ fail_unless(llist.tail == llist.head,
+ "tail and head should be the same");
+
+ /**
+ * testing Curl_llist_append
+ * case 2:
+ * list is not empty
+ * @assumptions:
+ * 1: the list head-next should be the newly created element
+ * 2: the list tail should be the newly created element
+ */
+ Curl_llist_append(&llist, &unusedData_case2, &case2_list);
+ fail_unless(llist.head->next->ptr == &unusedData_case2,
+ "the node next to head is not getting set correctly");
+ fail_unless(llist.tail->ptr == &unusedData_case2,
+ "the list tail is not getting set correctly");
+
+ /**
+ * testing Curl_llist_append
+ * case 3:
+ * list is has 2 members
+ * @assumptions:
+ * 1: the list head-next should remain the same
+ * 2: the list tail should be the newly created element
+ */
+ Curl_llist_append(&llist, &unusedData_case3, &case3_list);
+ fail_unless(llist.head->next->ptr == &unusedData_case2,
+ "the node next to head did not stay the same");
+ fail_unless(llist.tail->ptr == &unusedData_case3,
+ "the list tail is not getting set correctly");
+
+
+
Curl_llist_destroy(&llist, NULL);
Curl_llist_destroy(&llist_destination, NULL);
}