Skip to content

Use the correct CURLOPT_WRITEFUNCTION signature#21265

Closed
TedLyngmo wants to merge 1 commit intocurl:masterfrom
TedLyngmo:URLOPT_WRITEFUNCTION_sig
Closed

Use the correct CURLOPT_WRITEFUNCTION signature#21265
TedLyngmo wants to merge 1 commit intocurl:masterfrom
TedLyngmo:URLOPT_WRITEFUNCTION_sig

Conversation

@TedLyngmo
Copy link
Copy Markdown
Contributor

In order to not encourage users to use incompatible function pointers, change the callback function definitions to use char * instead of void * for the first argument.

Triggered by https://stackoverflow.com/questions/79921871/curl-c-c-library-based-application-produces-erronious-response-for-http-post-r#comment141032037_79921871 :
"The code was mostly modified from this example code, honestly I never knew this is wrong. Thanks for pointing it out."

@github-actions github-actions bot added the tests label Apr 8, 2026
@TedLyngmo TedLyngmo changed the title Use the correct URLOPT_WRITEFUNCTION signature Use the correct CURLOPT_WRITEFUNCTION signature Apr 8, 2026
In order to not encourage users to use incompatible function pointers,
change the callback function definitions to use `char *` instead of
`void *` for the first argument.

Triggered by https://stackoverflow.com/questions/79921871/curl-c-c-library-based-application-produces-erronious-response-for-http-post-r#comment141032037_79921871 :
"The code was mostly modified from
 [this example code](https://curl.se/libcurl/c/postinmemory.html),
 honestly I never knew this is wrong. Thanks for pointing it out."

Signed-off-by: Ted Lyngmo <ted@lyncon.se>
@TedLyngmo TedLyngmo force-pushed the URLOPT_WRITEFUNCTION_sig branch from 5304be6 to c54fd46 Compare April 8, 2026 07:39
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates libcurl tests and documentation/examples to use the canonical CURLOPT_WRITEFUNCTION callback prototype, aligning with curl_write_callback in the public headers and reducing the chance of users copying incompatible function pointer signatures.

Changes:

  • Update write callback prototypes from void * to char * for the first argument in docs/examples.
  • Adjust a libtest write callback to match the correct callback signature.
  • Update tutorial/FAQ text to reflect the correct prototype for user callbacks.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/libtest/lib3102.c Makes the test write callback match libcurl’s curl_write_callback signature.
docs/libcurl/opts/CURLINFO_TLS_SSL_PTR.md Fixes the example write callback signature to use char *.
docs/libcurl/libcurl-tutorial.md Updates the documented write callback prototype (including the C++ example).
docs/FAQ.md Updates the C++ callback example signature.
docs/examples/usercertinmem.c Corrects example write callback signature.
docs/examples/url2file.c Corrects example write callback signature.
docs/examples/synctime.c Corrects example write callback signature.
docs/examples/sftpget.c Corrects example write callback signature.
docs/examples/sessioninfo.c Corrects example write callback signature.
docs/examples/sepheaders.c Corrects example write callback signature.
docs/examples/postinmemory.c Corrects example write callback signature.
docs/examples/http2-pushinmemory.c Corrects example write callback signature.
docs/examples/hiperfifo.c Corrects example write callback signature.
docs/examples/ghiper.c Corrects example write callback signature.
docs/examples/getinmemory.c Corrects example write callback signature.
docs/examples/ftpuploadresume.c Corrects example write callback signature.
docs/examples/ftpsget.c Corrects example write callback signature.
docs/examples/ftpget.c Corrects example write callback signature.
docs/examples/ftp-delete.c Corrects example write callback signature.
docs/examples/externalsocket.c Corrects example write callback signature.
docs/examples/evhiperfifo.c Corrects example write callback signature.
docs/examples/ephiperfifo.c Corrects example write callback signature.
docs/examples/crawler.c Corrects example write callback signature.
docs/examples/chkspeed.c Corrects example write callback signature.
docs/examples/certinfo.c Corrects example write callback signature.
docs/examples/cacertinmem.c Corrects example write callback signature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@testclutch

This comment was marked as off-topic.

@bagder bagder closed this in 1356650 Apr 8, 2026
@bagder
Copy link
Copy Markdown
Member

bagder commented Apr 8, 2026

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

4 participants