Skip to content

Commit f17fb4b

Browse files
xerialclaude
andcommitted
refactor: Typed long* getinfo shim + keep CString cast (review)
- Replace the void* getinfo shim with a typed uni_curl_easy_getinfo_long(long*) so the response-code out-pointer isn't passed through an unsafe void* cast. - Restore the explicit .asInstanceOf[Ptr[Byte]] on the CString setopt path for cross-version clarity (CString = Ptr[CChar]). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 5e680f0 commit f17fb4b

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

uni/.native/src/main/resources/scala-native/uni_curl_shim.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ int uni_curl_easy_setopt_long(void *handle, int option, long value) {
3737
return curl_easy_setopt(handle, option, value);
3838
}
3939

40-
int uni_curl_easy_getinfo_ptr(void *handle, int info, void *value) {
40+
/* Typed long* out-parameter for CURLINFO_*_RESPONSE_CODE and other `long` infos. */
41+
int uni_curl_easy_getinfo_long(void *handle, int info, long *value) {
4142
return curl_easy_getinfo(handle, info, value);
4243
}

uni/.native/src/main/scala/wvlet/uni/http/CurlBindings.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ object CurlBindings:
104104
// src/main/resources/scala-native/uni_curl_shim.c, which forward to the real variadic functions.
105105
def uni_curl_easy_setopt_ptr(curl: CURL, option: CInt, value: Ptr[Byte]): CInt = extern
106106
def uni_curl_easy_setopt_long(curl: CURL, option: CInt, value: Long): CInt = extern
107-
def uni_curl_easy_getinfo_ptr(curl: CURL, info: CInt, value: Ptr[Byte]): CInt = extern
107+
def uni_curl_easy_getinfo_long(curl: CURL, info: CInt, value: Ptr[Long]): CInt = extern
108108

109109
@name("curl_easy_strerror")
110110
def easyStrerror(code: CInt): CString = extern
@@ -134,7 +134,7 @@ object CurlBindings:
134134
.uni_curl_easy_setopt_ptr(curl, option, parameter)
135135

136136
def curl_easy_setopt_str(curl: CURL, option: CInt, parameter: CString): CInt = Extern
137-
.uni_curl_easy_setopt_ptr(curl, option, parameter)
137+
.uni_curl_easy_setopt_ptr(curl, option, parameter.asInstanceOf[Ptr[Byte]])
138138

139139
def curl_easy_setopt_callback(
140140
curl: CURL,
@@ -150,7 +150,7 @@ object CurlBindings:
150150
.uni_curl_easy_setopt_ptr(curl, option, parameter.asInstanceOf[Ptr[Byte]])
151151

152152
def curl_easy_getinfo_long(curl: CURL, info: CInt, result: Ptr[Long]): CInt = Extern
153-
.uni_curl_easy_getinfo_ptr(curl, info, result.asInstanceOf[Ptr[Byte]])
153+
.uni_curl_easy_getinfo_long(curl, info, result)
154154

155155
def curl_easy_strerror(code: CInt): CString = Extern.easyStrerror(code)
156156
def curl_slist_append(list: Ptr[CurlSlist], str: CString): Ptr[CurlSlist] = Extern.slistAppend(

0 commit comments

Comments
 (0)