xref: /curl/docs/libcurl/curl_mime_free.md (revision 5a488251)
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
14Added-in: 7.56.0
15---
16
17# NAME
18
19curl_mime_free - free a previously built mime structure
20
21# SYNOPSIS
22
23~~~c
24#include <curl/curl.h>
25
26void curl_mime_free(curl_mime *mime);
27~~~
28
29# DESCRIPTION
30
31curl_mime_free(3) is used to clean up data previously built/appended
32with curl_mime_addpart(3) and other mime-handling functions. This must
33be called when the data has been used, which typically means after
34curl_easy_perform(3) has been called.
35
36The handle to free is the one you passed to the CURLOPT_MIMEPOST(3)
37option: attached sub part mime structures must not be explicitly freed as they
38are by the top structure freeing.
39
40**mime** is the handle as returned from a previous call to
41curl_mime_init(3) and may be NULL.
42
43Passing in a NULL pointer in *mime* makes this function return immediately
44with no action.
45
46# %PROTOCOLS%
47
48# EXAMPLE
49
50~~~c
51int main(void)
52{
53  CURL *curl = curl_easy_init();
54  if(curl) {
55    /* Build the mime message. */
56    curl_mime *mime = curl_mime_init(curl);
57
58    /* send off the transfer */
59
60    /* Free multipart message. */
61    curl_mime_free(mime);
62  }
63}
64~~~
65
66# %AVAILABILITY%
67
68# RETURN VALUE
69
70None
71