struct arrays are apparently a bit of a grey area ...
# kotlin-native
j
struct arrays are apparently a bit of a grey area in K/N:
Copy code
#!c
typedef struct request {
    int event_type;
    int iovec_count;
    int client_socket;
    struct iovec iov[];// <--- this 
};
in 1.5.31 this has no members, presumably silently errors during generation. in 1.6.0-RC it gains four members
Copy code
#!kotlin

@kotlinx.cinterop.internal.CStruct public final class request public constructor(rawPtr: kotlinx.cinterop.NativePtr /* = kotlin.native.internal.NativePtr */) : kotlinx.cinterop.CStructVar {
    @kotlinx.cinterop.internal.CStruct.VarType @kotlin.Deprecated public companion object : kotlinx.cinterop.CStructVar.Type {
    }
    public final var client_socket: <http://kotlin.Int|kotlin.Int> /* compiled code */
    public final var event_type: <http://kotlin.Int|kotlin.Int> /* compiled code */
    public final val iov: kotlinx.cinterop.CArrayPointer<platform.posix.iovec> /* = kotlinx.cinterop.CPointer<platform.posix.iovec> */ /* compiled code */
    public final var iovec_count: <http://kotlin.Int|kotlin.Int> /* compiled code */
}
I have been naively porting this source c code using nativeHeap.alloc() and finally come to the part where the code does malloc(request.size+iov.size*6) the pointer needs to be long lived as this gets passed to the linux kernel and is immediately freed when the kernel returns it. that said, the goal is using uring with stable kotlin pointers when im done porting the webserver sample, not to preserve c code. should i stick with a factory method that takes the array size and uses malloc or is there a similar OO snippet somewhere that can get the job done with an aligned flat byte-expanse?
e