/* Add a timestamp to the list of timeouts. Keep the list sorted so that head of list is always the timeout nearest in time.  */
static CURLMcode multi_addtimeout(struct Curl_easy *data, struct curltime *stamp, expire_id eid)
/* Add a timestamp to the list of timeouts. Keep the list sorted so that head of list is always the timeout nearest in time.  */
static CURLMcode multi_addtimeout(struct Curl_easy *data, struct curltime *stamp, expire_id eid)
{
  struct curl_llist_element *e;
  struct time_node *node;
  struct curl_llist_element *prev = NULL;
  size_t n;
  struct curl_llist *timeoutlist = &data->state.timeoutlist;
  node = &data->state.expires[eid];
  memcpy(&node->time, stamp, sizeof(*stamp));
  node->eid = eid;
  n = Curl_llist_count(timeoutlist);
  if(n) {
    for(e = timeoutlist->head; e; e = e->next) {
      struct time_node *check = (struct time_node *)e->ptr;
      timediff_t diff = Curl_timediff(check->time, node->time);
      if(diff > 0)
        break;
      prev = e;
    }
  }
  Curl_llist_insert_next(timeoutlist, prev, node, &node->list);
  return CURLM_OK;
}