diff --git a/objcutil.go b/objcutil.go index 8b49dd2e..725404c8 100644 --- a/objcutil.go +++ b/objcutil.go @@ -108,14 +108,14 @@ void* getNSArrayItem(void *ptr, int i) return [arr objectAtIndex:i]; } -const char *getUUID() + char *getUUID() { - const char *ret; + char *ret; @autoreleasepool { NSString *uuid = [[NSUUID UUID] UUIDString]; - ret = [uuid UTF8String]; + ret = strdup([uuid UTF8String]); } - return ret; + return ret } */ import "C" diff --git a/virtualization.go b/virtualization.go index 9e335d50..b6c011c2 100644 --- a/virtualization.go +++ b/virtualization.go @@ -93,9 +93,9 @@ type machineStatus struct { // A new dispatch queue will create when called this function. // Every operation on the virtual machine must be done on that queue. The callbacks and delegate methods are invoked on that queue. func NewVirtualMachine(config *VirtualMachineConfiguration) *VirtualMachine { - // should not call Free function for this string. cs := getUUID() dispatchQueue := C.makeDispatchQueue(cs.CString()) + cs.Free() status := cgo.NewHandle(&machineStatus{ state: VirtualMachineState(0),