xref: /curl/docs/libcurl/curl_slist_free_all.md (revision 1e769526)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: curl_slist_free_all
5Section: 3
6Source: libcurl
7See-also:
8  - curl_slist_append (3)
9Protocol:
10  - All
11Added-in: 7.1
12---
13
14# NAME
15
16curl_slist_free_all - free an entire curl_slist list
17
18# SYNOPSIS
19
20~~~c
21#include <curl/curl.h>
22
23void curl_slist_free_all(struct curl_slist *list);
24~~~
25
26# DESCRIPTION
27
28curl_slist_free_all() removes all traces of a previously built curl_slist
29linked list.
30
31Passing in a NULL pointer in *list* makes this function return immediately
32with no action.
33
34Any use of the **list** after this function has been called and have returned,
35is illegal.
36
37# %PROTOCOLS%
38
39# EXAMPLE
40
41~~~c
42int main(void)
43{
44  CURL *handle;
45  struct curl_slist *slist = NULL;
46
47  slist = curl_slist_append(slist, "X-libcurl: coolness");
48
49  if(!slist)
50    return -1;
51
52  curl_easy_setopt(handle, CURLOPT_HTTPHEADER, slist);
53
54  curl_easy_perform(handle);
55
56  curl_slist_free_all(slist); /* free the list again */
57}
58~~~
59
60# %AVAILABILITY%
61
62# RETURN VALUE
63
64Nothing.
65