From: Patrick Monnerat Date: Mon, 24 Nov 2025 13:57:38 +0000 (+0100) Subject: slist: constify Curl_slist_append_nodup() string argument X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=74bd3e2f98b26b283dbdb5af543e0c43e61a6155;p=thirdparty%2Fcurl.git slist: constify Curl_slist_append_nodup() string argument Although finally stored as a non-const pointer, the string is intended to be left unchanged. This change allows using the function without the need of a cast for const pointers. Closes #19692 --- diff --git a/lib/slist.c b/lib/slist.c index 366b247609..88fdd8a2ba 100644 --- a/lib/slist.c +++ b/lib/slist.c @@ -58,7 +58,8 @@ static struct curl_slist *slist_get_last(struct curl_slist *list) * If an error occurs, NULL is returned and the string argument is NOT * released. */ -struct curl_slist *Curl_slist_append_nodup(struct curl_slist *list, char *data) +struct curl_slist *Curl_slist_append_nodup(struct curl_slist *list, + const char *data) { struct curl_slist *last; struct curl_slist *new_item; @@ -70,7 +71,7 @@ struct curl_slist *Curl_slist_append_nodup(struct curl_slist *list, char *data) return NULL; new_item->next = NULL; - new_item->data = data; + new_item->data = CURL_UNCONST(data); /* if this is the first item, then new_item *is* the list */ if(!list) diff --git a/lib/slist.h b/lib/slist.h index 9561fd0226..47a30824db 100644 --- a/lib/slist.h +++ b/lib/slist.h @@ -36,6 +36,6 @@ struct curl_slist *Curl_slist_duplicate(struct curl_slist *inlist); * it to the list. */ struct curl_slist *Curl_slist_append_nodup(struct curl_slist *list, - char *data); + const char *data); #endif /* HEADER_CURL_SLIST_H */