Hi, in the file engine.go you have:
func NewEngine(config EngineConfig) Engine {
var newEngine = engine{}
var loaderHandlerIdPtr C.uintptr_t
var customNodeHandlerIdPtr C.uintptr_t
if config.Loader != nil {
newEngine.loaderHandler = cgo.NewHandle(wrapLoader(config.Loader))
loaderHandlerIdPtr = C.uintptr_t(newEngine.loaderHandler)
newEngine.loaderHandlerIdPtr = &loaderHandlerIdPtr
}
if config.CustomNodeHandler != nil {
newEngine.customNodeHandler = cgo.NewHandle(wrapCustomNodeHandler(config.CustomNodeHandler))
customNodeHandlerIdPtr = C.uintptr_t(newEngine.customNodeHandler)
newEngine.customNodeHandlerIdPtr = &customNodeHandlerIdPtr
}
newEngine.enginePtr = C.zen_engine_new_golang(&loaderHandlerIdPtr, &customNodeHandlerIdPtr)
return newEngine
}
Is there any specific reason for returning a value instead of a pointer? I think we usually create just one instance of the engine and reuse it throughout the project, so heap allocations aren't a problem.
Hi, in the file engine.go you have:
Is there any specific reason for returning a value instead of a pointer? I think we usually create just one instance of the engine and reuse it throughout the project, so heap allocations aren't a problem.