typedef struct Hooks {
void *(*malloc_fn)(size_t sz);
void (*free_fn)(void *ptr);
} Hooks;
type Hooks struct {
MallocFn c.Pointer
FreeFn c.Pointer
}
Due to the characteristics of LLGo, an anonymous function type cannot be directly declared as a Field Type. Currently, the Field Type for an anonymous function is only mapped to c.Pointer, but this causes the original type information to be lost. To solve this problem, we can additionally declare a function type annotated with llgo:type C and reference it.
typedef struct Hooks {
void *(*malloc_fn)(size_t sz);
void (*free_fn)(void *ptr);
} Hooks;
// llgo:type C
type LLGO_HOOKS_MallocFn func(c.SizeT) c.Pointer
// llgo:type C
type LLGO_HOOKS_FreeFn func(c.Pointer)
type Hooks struct {
MallocFn LLGO_HOOKS_MallocFn
FreeFn LLGO_HOOKS_FreeFn
}
Due to the characteristics of LLGo, an anonymous function type cannot be directly declared as a Field Type. Currently, the Field Type for an anonymous function is only mapped to
c.Pointer, but this causes the original type information to be lost. To solve this problem, we can additionally declare a function type annotated with llgo:type C and reference it.