curl-library
Re: Freeing CURLFORM_BUFFERPTR
Date: Sat, 2 Aug 2014 23:04:33 +0200 (CEST)
On Sat, 2 Aug 2014, David Siebörger wrote:
> curl_formadd(3) says that the buffer provided with CURLFORM_BUFFERPTR "must
> not be freed until after curl_easy_cleanup(3) is called." Is that correct?
It could probably benefit from a slight rewording. The point is that the
option passes on a pointer to libcurl and libcurl will use that pointer when
referring to that data (without doing any copy) so you need to make sure the
data is around for as long as libcurl may need it.
> I'd imagine that once the request has been completed and curl_formfree has
> been called, curl would've lost the pointer to the buffer and it'd be safe
> to free it, or at least that curl wouldn't have any reason to look back at
> what it had uploaded previously.
You could easily call curl_easy_perform() again and then it would use that
buffer again...
> My application needs to submit a file via HTTPS once a minute, so I'd prefer
> not to have curl_easy_cleanup tear the connection down every time just so
> that the buffer can be freed.
If you just make sure you don't let libcurl use the buffer again that's fine.
-- / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-08-02