lidavidm commented on code in PR #893:
URL: https://github.com/apache/arrow-adbc/pull/893#discussion_r1261534716
##########
go/adbc/pkg/_tmpl/driver.go.tmpl:
##########
@@ -115,6 +198,44 @@ func getFromHandle[T any](ptr unsafe.Pointer) *T {
return cgo.Handle((uintptr)(*hptr)).Value().(*T)
}
+func exportStringOption(val string, out *C.char, length *C.size_t)
C.AdbcStatusCode {
+ lenWithTerminator := C.size_t(len(val) + 1)
+ if lenWithTerminator <= *length {
+ // TODO: doesn't this reallocate the string? can we avoid this?
+ C.strncpy(out, (*C.char)(C.CString(val)), lenWithTerminator)
+ }
+ *length = lenWithTerminator
+ return C.ADBC_STATUS_OK
+}
+
+func exportBytesOption(val []byte, out *C.uint8_t, length *C.size_t)
C.AdbcStatusCode {
+ if C.size_t(len(val)) <= *length {
+ sink := fromCArr[byte]((*byte)(out), int(*length))
+ copy(sink, val)
+ }
Review Comment:
No, there's no point. The definition in adbc.h describes how to handle this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]