-----Original Message-----
From: curl-library <curl-library-boun...@cool.haxx.se> On Behalf Of Tomalak 
Geret'kal via curl-library
Sent: Monday, February 22, 2021 5:16 PM
To: curl-library@cool.haxx.se
Cc: Tomalak Geret'kal <t...@kera.name>
Subject: Re: Non-constness of field "data" in "struct curl_blob" with setopt

> Why? The data isn't going to be modified. Just cast to `void*`. The `const` 
> is erased just like the `char` is in this particular use case.

I think we overall agree about how it should be used (cast it void* and if you 
want a copy, cast it to void* + use the flag), but the API doesn't carry that.
Think of "memcpy". The destination is "void*" and gets written to. The source 
is "const void*".
In fact, the compilers may raise a warning (depending on warning level) if you 
try to assign a "const char*" to a "void*", but not if you assign to a "const 
void*".

I'm not sure how much sense it make to change the API now, so maybe documenting 
it is enough.
Maybe I'm also missing some general "guidelines" about "curl_easy_setopt" which 
guarantee that the parameters won't be modified by "curl_easy_setopt".

Also sorry about the non-utf8 characters. :(
Hopefully my mail client is correctly configured now.

Cheers,
Laurent


-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html

Reply via email to