Skip to content

build: tidy up and dedupe strdup functions#20497

Closed
vszakats wants to merge 25 commits intocurl:masterfrom
vszakats:dedupedup
Closed

build: tidy up and dedupe strdup functions#20497
vszakats wants to merge 25 commits intocurl:masterfrom
vszakats:dedupedup

Conversation

@vszakats
Copy link
Member

@vszakats vszakats commented Feb 2, 2026

  • de-dupe lib/src strdup/memdup functions into curlx.
  • introduce CURLX_STRDUP_LOW() for mapping strdup(), and to do it at
    one place within the code, in curl_setup.h.
  • tests/server: use curlx_strdup(). (Also to fix building without
    a system strdup().)
  • curlx/curlx.h: shorten and tidy up.
  • adjust Windows build path to not need HAVE_STRDUP.
  • build: stop detecting HAVE_STRDUP on Windows.

  • it looks like Curl_strdup() isn't used except for one place. Make makes me doubt curl builds without HAVE_STRDUP. tests/server uses strdup without checking HAVE_STRDUP.
    My assessment is that this was the case for a long time, but only became apparent via a bare grep after 193cb00 build: stop overriding standard memory allocation functions #19626.
  • test the above more. possibly it applied to tests only, and certainly to examples.
    edit: confirmed that in 8.17 curl and libcurl built without strdup, but tests and examples did not.
  • move dropping HAVE_STRDUP to deparate PR.
  • rename functions moved to curlx to have curlx_ prefixes.
  • classic mac may be a platform without strdup (deducting from config-mac.h, which missed setting HAVE_STRDUP). 919c97f. edit: classic mac includes extra/strdup.h, so it also has one.

Separate PRs:

@vszakats vszakats marked this pull request as draft February 2, 2026 13:19
@vszakats vszakats changed the title try to dedupe strdup implementations into curlx try to dedupe strdup functions into curlx Feb 2, 2026
@github-actions github-actions bot added the tests label Feb 2, 2026
@vszakats vszakats changed the title try to dedupe strdup functions into curlx build: tidy up and reduce strdup functions Feb 2, 2026
@vszakats vszakats marked this pull request as ready for review February 2, 2026 21:39
@vszakats vszakats force-pushed the dedupedup branch 2 times, most recently from 44db2b7 to 65d4335 Compare February 3, 2026 00:00
@vszakats vszakats marked this pull request as draft February 3, 2026 02:00
@vszakats vszakats marked this pull request as ready for review February 3, 2026 12:10
@vszakats vszakats changed the title build: tidy up and reduce strdup functions build: tidy up and dedupe strdup functions Feb 3, 2026
@vszakats vszakats closed this in 31a4f41 Feb 3, 2026
@vszakats vszakats deleted the dedupedup branch February 3, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant