git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC PATCH] http: use xmalloc with cURL

From
Carlo Marcelo Arenas Belón <carenas@gmail.com>
Date
Aug 10, 2019, 22:02 UTC
Message-ID
<20190810220251.3684-1-carenas@gmail.com>

4a30976e28 ([PATCH] support older versions of libcurl, 2005-07-28) added support for conditionally initializing cURL but when f0ed8226c9 (Add custom memory allocator to MinGW and MacOS builds, 2009-05-31) that support wasn't updated to make sure cURL will use the same allocator than git if compiled with USE_NED_ALLOCATOR=YesPlease (usually done in Windows)

tested in macOS 10.14.6 with the system provided cURL (7.54.0) and latest (7.65.3) and while the API used should be added starting around 7.12.0 (mid 2014). couldn't get a release that old to build and therefore the current mismatch is unlikely to be found while testing because of that.

cURL is very strict about its allocator being thread safe and so that might be an issue to look for.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
---
 http.h | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/http.h b/http.h
index b429f1cf04..59ec4cbd30 100644
--- a/http.h
+++ b/http.h
@@ -27,6 +27,9 @@
 #endif
 #if LIBCURL_VERSION_NUM < 0x070800
 #define curl_global_init(a) do { /* nothing */ } while (0)
+#else
+#define curl_global_init(a) curl_global_init_mem(a, xmalloc, free, \
+						xrealloc, xstrdup, xcalloc)
 #endif
 
 #if (LIBCURL_VERSION_NUM < 0x070c04) || (LIBCURL_VERSION_NUM == 0x071000)
-- 
2.23.0.rc2
Next: Daniel Stenberg
Message 1 of 11 in “http: use xmalloc with cURL”
  1. http: use xmalloc with cURLCarlo Marcelo Arenas Belón, Aug 10, 2019
  2. Daniel StenbergAug 10, 2019
  3. Carlo ArenasAug 10, 2019
  4. Johannes SchindelinAug 11, 2019
  5. Carlo ArenasAug 11, 2019
  6. Johannes SchindelinAug 12, 2019
  7. Jeff KingAug 12, 2019
  8. Junio C HamanoAug 12, 2019
  9. Jeff KingAug 12, 2019
  10. Johannes SchindelinAug 13, 2019
  11. Jeff KingAug 14, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.