glib/glib.go
func ValueAlloc() (*Value, error) {
	c := C._g_value_alloc()
	if c == nil {
		return nil, errNilPtr
	}

	v := &Value{c}

	//An allocated GValue is not guaranteed to hold a value that can be unset
	//We need to double check before unsetting, to prevent:
	//`g_value_unset: assertion 'G_IS_VALUE (value)' failed`
	runtime.SetFinalizer(v, func(f *Value) {
		if t, _, err := f.Type(); err != nil || t == TYPE_INVALID || t == TYPE_NONE {
			C.g_free(C.gpointer(f.native()))
			return
		}

		f.unset()
	})

	return v, nil
}
func ValueAlloc() (*Value, error) {
	c := C._g_value_alloc()
	if c == nil {
		return nil, errNilPtr
	}

	v := &Value{c}

	//An allocated GValue is not guaranteed to hold a value that can be unset
	//We need to double check before unsetting, to prevent:
	//`g_value_unset: assertion 'G_IS_VALUE (value)' failed`
	runtime.SetFinalizer(v, func(f *Value) {
		if t, _, err := f.Type(); err != nil || t == TYPE_INVALID || t == TYPE_NONE {
			C.g_free(C.gpointer(f.native()))
			return
		}

		f.unset()
	})

	return v, nil
}
func ValueAlloc ( ) ( * Value , error ) { c := C . _g_value_alloc ( ) if c == nil { return nil , errNilPtr } v := & Value { c } //An allocated GValue is not guaranteed to hold a value that can be unset //We need to double check before unsetting, to prevent: //`g_value_unset: assertion 'G_IS_VALUE (value)' failed` runtime . SetFinalizer ( v , func ( f * Value ) { if t , _ , err := f . Type ( ) ; err != nil || t == TYPE_INVALID || t == TYPE_NONE { C . g_free ( C . gpointer ( f . native ( ) ) ) return } f . unset ( ) } ) return v , nil }
// ValueAlloc allocates a Value and sets a runtime finalizer to call
// g_value_unset() on the underlying GValue after leaving scope.
// ValueAlloc() returns a non-nil error if the allocation failed.
ValueAlloc allocates a Value and sets a runtime finalizer to call g_value_unset () on the underlying GValue after leaving scope . ValueAlloc () returns a non - nil error if the allocation failed .