curl\_free(3) Library Functions Manual curl\_free(3)

# [NAME](#NAME)

curl\_free - reclaim memory that has been obtained through a libcurl call

# [SYNOPSIS](#SYNOPSIS)

```
#include <curl/curl.h>
void curl_free(void *ptr);
```

# [DESCRIPTION](#DESCRIPTION)

curl\_free reclaims memory that has been obtained through a libcurl call. Use [*curl\_free(3)*](/man/os/curl/curl_free.3) instead of free() to avoid anomalies that can result from differences in memory management between your application and libcurl.

Passing in a NULL pointer in *ptr* makes this function return immediately with no action.

# [PROTOCOLS](#PROTOCOLS)

This functionality affects all supported protocols

# [EXAMPLE](#EXAMPLE)

```
int main(void)
{


  char *width = curl_getenv("COLUMNS");


  if(width) {


    /* it was set */


    curl_free(width);


  }
}
```

# [AVAILABILITY](#AVAILABILITY)

Added in curl 7.1

# [RETURN VALUE](#RETURN_VALUE)

None

# [SEE ALSO](#SEE_ALSO)

[**curl\_easy\_escape**(3)](/man/os/curl/curl_easy_escape.3), [**curl\_easy\_unescape**(3)](/man/os/curl/curl_easy_unescape.3)

2026-10-14 libcurl

---

Document: curl_free(3) from curl 8.23.0-r0 (Chainguard OS)
Source: https://github.com/curl/curl.git
