pitrou commented on a change in pull request #11919:
URL: https://github.com/apache/arrow/pull/11919#discussion_r766018570



##########
File path: r/src/py-to-r.cpp
##########
@@ -21,6 +21,41 @@
 
 #include <arrow/c/bridge.h>
 
+// [[arrow::export]]
+double external_pointer_addr_double(SEXP external_pointer) {
+  // potentially lossy conversion to double needed for the current
+  // implementation of import/export to Python
+  return reinterpret_cast<uintptr_t>(R_ExternalPtrAddr(external_pointer));
+}
+
+// [[arrow::export]]
+std::string external_pointer_addr_character(SEXP external_pointer) {
+  void* ptr_void = R_ExternalPtrAddr(external_pointer);
+  uint64_t ptr_int64 = reinterpret_cast<uintptr_t>(ptr_void);
+  char ptr_chars[128];
+  memset(ptr_chars, 0, 128);
+  int nchar = sprintf(ptr_chars, "%llu", ptr_int64);

Review comment:
       You can use `std::to_string`: 
https://en.cppreference.com/w/cpp/string/basic_string/to_string




-- 
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]


Reply via email to