+static inline LDKStr str_ref_to_owned_c(jstring str) {
+ uint32_t *str_len = (uint32_t*)str;
+ char* newchars = MALLOC(*str_len + 1, "String chars");
+ memcpy(newchars, (const char*)(str + 4), *str_len);
+ newchars[*str_len] = 0;
+ LDKStr res= {
+ .chars = newchars,
+ .len = *str_len,
+ .chars_is_owned = true
+ };
+ return res;
+}