xref: /curl/docs/libcurl/curl_mime_free.md (revision b935fd4a)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: curl_mime_free
5Section: 3
6Source: libcurl
7See-also:
8  - curl_free (3)
9  - curl_mime_init (3)
10Protocol:
11  - HTTP
12  - IMAP
13  - SMTP
14---
15
16# NAME
17
18curl_mime_free - free a previously built mime structure
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25void curl_mime_free(curl_mime *mime);
26~~~
27
28# DESCRIPTION
29
30curl_mime_free(3) is used to clean up data previously built/appended
31with curl_mime_addpart(3) and other mime-handling functions. This must
32be called when the data has been used, which typically means after
33curl_easy_perform(3) has been called.
34
35The handle to free is the one you passed to the CURLOPT_MIMEPOST(3)
36option: attached sub part mime structures must not be explicitly freed as they
37are by the top structure freeing.
38
39**mime** is the handle as returned from a previous call to
40curl_mime_init(3) and may be NULL.
41
42Passing in a NULL pointer in *mime* makes this function return immediately
43with no action.
44
45# EXAMPLE
46
47~~~c
48int main(void)
49{
50  CURL *curl = curl_easy_init();
51  if(curl) {
52    /* Build the mime message. */
53    curl_mime *mime = curl_mime_init(curl);
54
55    /* send off the transfer */
56
57    /* Free multipart message. */
58    curl_mime_free(mime);
59  }
60}
61~~~
62
63# AVAILABILITY
64
65As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0.
66
67# RETURN VALUE
68
69None
70