xref: /curl/docs/libcurl/curl_free.md (revision 3040971d)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: curl_free
5Section: 3
6Source: libcurl
7See-also:
8  - curl_easy_escape (3)
9  - curl_easy_unescape (3)
10Protocol:
11  - All
12Added-in: 7.1
13---
14
15# NAME
16
17curl_free - reclaim memory that has been obtained through a libcurl call
18
19# SYNOPSIS
20
21~~~c
22#include <curl/curl.h>
23
24void curl_free(void *ptr);
25~~~
26
27# DESCRIPTION
28
29curl_free reclaims memory that has been obtained through a libcurl call. Use
30curl_free(3) instead of free() to avoid anomalies that can result from
31differences in memory management between your application and libcurl.
32
33Passing in a NULL pointer in *ptr* makes this function return immediately
34with no action.
35
36# %PROTOCOLS%
37
38# EXAMPLE
39
40~~~c
41int main(void)
42{
43  char *width = curl_getenv("COLUMNS");
44  if(width) {
45    /* it was set */
46    curl_free(width);
47  }
48}
49~~~
50
51# %AVAILABILITY%
52
53# RETURN VALUE
54
55None
56