I have a question regarding Kotlin Native and CInterop. So at the moment I am building a dynamic library to use as a JVM jvmti agent (with little C glue code).
Now I have the case that some jvmti functions will allocate and deallocate memory instead that I allocate/deallocate the pointers. Here is an example in C:
char* class_sig; (*jvmti)->GetClassSignature(object_klass, &class_sig, NULL) do something with class_sig.... (*jvmti)->Deallocate((unsigned char*) class_sig);
Fairly easy in C, but with Kotlin Native I struggle a little bit. For me that case would mean, that I cant call nativeheap.alloc or use memscope and alloc, but instead have to pass an uninitialized pointer, or am I wrong?
I tried several things, but I just can’t make it work. When the CPointer for example will be set to null and I pass the pointer to the jvmti function, it stays null after that.
Am I thinking too complicated, is it easier than I think or is that case just not possible in Kotlin Native?