On 4/20/23 12:31, Timothe Litt via curl-library wrote:
On 20-Apr-23 05:24, Frank Gevaerts via curl-library wrote:
On Wed, Apr 19, 2023 at 06:47:42PM +0200, Andreas Falkenhahn via curl-library
wrote:
Many manpages of curl options that take a string say: "The application does not have
to keep the string around after setting this option". Does this imply that curl
options which do NOT contain this phrase must ensure the string pointer passed to the
option remains valid after calling curl_easy_setopt()?
In principle, yes. Oversights happen so some manpages might not have
that paragraph while they should though.
If there are any cases where the string is not copied and must be
retained, the documentation should say so explicitly.
The documentation DOES say so.
The only exception is CURLOPT_POSTFIELDS, because the postfield string
might be associated to the CURLOPT_POSTFIELDSIZE option rather than
being null-terminated. There is however an alternate option
CURLOPT_COPYPOSTFIELDS.
From the CURLOPT_POSTFIELDS man page:
---
The data pointed to is NOT copied by the library: as a consequence, it
must be preserved by the calling application until the
associated
transfer finishes. This behavior can be changed (so libcurl
does copy
the data) by setting the CURLOPT_COPYPOSTFIELDS(3) option.
---
The only other option that passes a character pointer and is not subject
to copying is CURLOPT_ERRORBUFFER, because it specifies an output
buffer, not an input string.(directions seen from libcurl standview, of
course).
Blob data copying is controlled by a flag in the curl_blob itself.
The rest is pretty orthogonal.
Patrick
--
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette: https://curl.se/mail/etiquette.html