# What's up with `ptr()` methods? We use `runtime.SetFinalizer` to free all objects we allocate from C. This is intended to make usage of the API much simpler since you don't have to close/free anything. The tricky part here though is laid out in `runtime.SetFinalizer`'s documentation which is that
(s string)
| 50 | |
| 51 | // Convert a Go string into an owned `wasm_byte_vec_t` |
| 52 | func stringToByteVec(s string) C.wasm_byte_vec_t { |
| 53 | vec := C.wasm_byte_vec_t{} |
| 54 | C.wasm_byte_vec_new_uninitialized(&vec, C.size_t(len(s))) |
| 55 | C.memcpy(unsafe.Pointer(vec.data), unsafe.Pointer(C._GoStringPtr(s)), vec.size) |
| 56 | runtime.KeepAlive(s) |
| 57 | return vec |
| 58 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…