/* Curl_slist_duplicate() duplicates a linked list. It always returns the address of the first record of the cloned list or NULL in case of an error (or if the input list was NULL).  */
struct curl_slist* Curl_slist_duplicate(struct curl_slist *inlist)
/* Curl_slist_duplicate() duplicates a linked list. It always returns the address of the first record of the cloned list or NULL in case of an error (or if the input list was NULL).  */
struct curl_slist* Curl_slist_duplicate(struct curl_slist *inlist)
{
  struct curl_slist *outlist = NULL;
  struct curl_slist *tmp;
  while(inlist) {
    tmp = curl_slist_append(outlist, inlist->data);
    if(!tmp) {
      curl_slist_free_all(outlist);
      return NULL;
    }
    outlist = tmp;
    inlist = inlist->next;
  }
  return outlist;
}