diff --git a/sdl/audio.go b/sdl/audio.go index 4b462ac2..399b9f8b 100644 --- a/sdl/audio.go +++ b/sdl/audio.go @@ -356,7 +356,7 @@ func GetAudioDriver(index int) string { // (https://wiki.libsdl.org/SDL_AudioInit) func AudioInit(driverName string) error { _driverName := C.CString(driverName) - defer C.SDL_free(unsafe.Pointer(_driverName)) + defer C.free(unsafe.Pointer(_driverName)) if C.SDL_AudioInit(_driverName) != 0 { return GetError() } @@ -403,7 +403,7 @@ func OpenAudioDevice(device string, isCapture bool, desired, obtained *AudioSpec if device == "" { _device = nil } - defer C.SDL_free(unsafe.Pointer(_device)) + defer C.free(unsafe.Pointer(_device)) if id := AudioDeviceID(C.SDL_OpenAudioDevice(_device, C.int(Btoi(isCapture)), desired.cptr(), obtained.cptr(), C.int(allowedChanges))); id > 0 { return id, nil } @@ -454,8 +454,8 @@ func LoadWAVRW(src *RWops, freeSrc bool) ([]byte, *AudioSpec) { func LoadWAV(file string) ([]byte, *AudioSpec) { _file := C.CString(file) _rb := C.CString("rb") - defer C.SDL_free(unsafe.Pointer(_file)) - defer C.SDL_free(unsafe.Pointer(_rb)) + defer C.free(unsafe.Pointer(_file)) + defer C.free(unsafe.Pointer(_rb)) var _audioBuf *C.Uint8 var _audioLen C.Uint32 diff --git a/sdl/clipboard.go b/sdl/clipboard.go index 6afb2fc6..1b26bc8d 100644 --- a/sdl/clipboard.go +++ b/sdl/clipboard.go @@ -8,7 +8,7 @@ import "unsafe" // (https://wiki.libsdl.org/SDL_SetClipboardText) func SetClipboardText(text string) error { _text := C.CString(text) - defer C.SDL_free(unsafe.Pointer(_text)) + defer C.free(unsafe.Pointer(_text)) if C.SDL_SetClipboardText(_text) < 0 { return GetError() } diff --git a/sdl/filesystem.go b/sdl/filesystem.go index 90f7e679..1f724b2e 100644 --- a/sdl/filesystem.go +++ b/sdl/filesystem.go @@ -42,8 +42,8 @@ func GetBasePath() string { func GetPrefPath(org, app string) string { _org := C.CString(org) _app := C.CString(app) - defer C.SDL_free(unsafe.Pointer(_org)) - defer C.SDL_free(unsafe.Pointer(_app)) + defer C.free(unsafe.Pointer(_org)) + defer C.free(unsafe.Pointer(_app)) _val := C.SDL_GetPrefPath(_org, _app) defer C.SDL_free(unsafe.Pointer(_val)) return C.GoString(_val) diff --git a/sdl/gamecontroller.go b/sdl/gamecontroller.go index 69b24535..ebc49e9c 100644 --- a/sdl/gamecontroller.go +++ b/sdl/gamecontroller.go @@ -389,7 +389,7 @@ func (btn GameControllerButton) c() C.SDL_GameControllerButton { // (https://wiki.libsdl.org/SDL_GameControllerAddMapping) func GameControllerAddMapping(mappingString string) int { _mappingString := C.CString(mappingString) - defer C.SDL_free(unsafe.Pointer(_mappingString)) + defer C.free(unsafe.Pointer(_mappingString)) return int(C.SDL_GameControllerAddMapping(_mappingString)) } @@ -555,7 +555,7 @@ func GameControllerUpdate() { // (https://wiki.libsdl.org/SDL_GameControllerGetAxisFromString) func GameControllerGetAxisFromString(pchString string) GameControllerAxis { _pchString := C.CString(pchString) - defer C.SDL_free(unsafe.Pointer(_pchString)) + defer C.free(unsafe.Pointer(_pchString)) return GameControllerAxis(C.SDL_GameControllerGetAxisFromString(_pchString)) } @@ -587,7 +587,7 @@ func (ctrl *GameController) Axis(axis GameControllerAxis) int16 { // (https://wiki.libsdl.org/SDL_GameControllerGetButtonFromString) func GameControllerGetButtonFromString(pchString string) GameControllerButton { _pchString := C.CString(pchString) - defer C.SDL_free(unsafe.Pointer(_pchString)) + defer C.free(unsafe.Pointer(_pchString)) return GameControllerButton(C.SDL_GameControllerGetButtonFromString(_pchString)) } diff --git a/sdl/hidapi.go b/sdl/hidapi.go index e3cbfa97..6bfa7a40 100644 --- a/sdl/hidapi.go +++ b/sdl/hidapi.go @@ -246,7 +246,7 @@ func HIDOpen(vendorID, productID uint16, _serialNumber *C.wchar_t) (device *HIDD // (https://wiki.libsdl.org/SDL_hid_open_path) func HIDOpenPath(path string, exclusive bool) (device *HIDDevice) { _path := C.CString(path) - defer C.SDL_free(unsafe.Pointer(_path)) + defer C.free(unsafe.Pointer(_path)) _exclusive := C.int(0) if exclusive { _exclusive = C.int(1) diff --git a/sdl/hints.go b/sdl/hints.go index 87641f89..5a5ed6c8 100644 --- a/sdl/hints.go +++ b/sdl/hints.go @@ -343,8 +343,8 @@ func (hp HintPriority) c() C.SDL_HintPriority { func SetHintWithPriority(name, value string, hp HintPriority) bool { _name := C.CString(name) _value := C.CString(value) - defer C.SDL_free(unsafe.Pointer(_name)) - defer C.SDL_free(unsafe.Pointer(_value)) + defer C.free(unsafe.Pointer(_name)) + defer C.free(unsafe.Pointer(_value)) return C.SDL_SetHintWithPriority(_name, _value, hp.c()) > 0 } @@ -353,8 +353,8 @@ func SetHintWithPriority(name, value string, hp HintPriority) bool { func SetHint(name, value string) bool { _name := C.CString(name) _value := C.CString(value) - defer C.SDL_free(unsafe.Pointer(_name)) - defer C.SDL_free(unsafe.Pointer(_value)) + defer C.free(unsafe.Pointer(_name)) + defer C.free(unsafe.Pointer(_value)) return C.SDL_SetHint(_name, _value) > 0 } @@ -362,7 +362,7 @@ func SetHint(name, value string) bool { // (https://wiki.libsdl.org/SDL_ResetHint) func ResetHint(name string) bool { _name := C.CString(name) - defer C.SDL_free(unsafe.Pointer(_name)) + defer C.free(unsafe.Pointer(_name)) return C.SDL_ResetHint(_name) == C.SDL_TRUE } @@ -370,7 +370,7 @@ func ResetHint(name string) bool { // (https://wiki.libsdl.org/SDL_GetHint) func GetHint(name string) string { _name := C.CString(name) - defer C.SDL_free(unsafe.Pointer(_name)) + defer C.free(unsafe.Pointer(_name)) return C.GoString(C.SDL_GetHint(_name)) } diff --git a/sdl/joystick.go b/sdl/joystick.go index d641286c..8d582b69 100644 --- a/sdl/joystick.go +++ b/sdl/joystick.go @@ -505,7 +505,7 @@ func JoystickGetDeviceInstanceID(index int) JoystickID { func JoystickGetGUIDString(guid JoystickGUID) string { _pszGUID := make([]rune, 1024) pszGUID := C.CString(string(_pszGUID[:])) - defer C.SDL_free(unsafe.Pointer(pszGUID)) + defer C.free(unsafe.Pointer(pszGUID)) C.SDL_JoystickGetGUIDString(guid.c(), pszGUID, C.int(unsafe.Sizeof(_pszGUID))) return C.GoString(pszGUID) } @@ -514,7 +514,7 @@ func JoystickGetGUIDString(guid JoystickGUID) string { // (https://wiki.libsdl.org/SDL_JoystickGetGUIDFromString) func JoystickGetGUIDFromString(pchGUID string) JoystickGUID { _pchGUID := C.CString(pchGUID) - defer C.SDL_free(unsafe.Pointer(_pchGUID)) + defer C.free(unsafe.Pointer(_pchGUID)) return (JoystickGUID)(C.SDL_JoystickGetGUIDFromString(_pchGUID)) } diff --git a/sdl/keyboard.go b/sdl/keyboard.go index 45aa364d..fb63d25a 100644 --- a/sdl/keyboard.go +++ b/sdl/keyboard.go @@ -101,7 +101,7 @@ func GetScancodeName(code Scancode) string { // (https://wiki.libsdl.org/SDL_GetScancodeFromName) func GetScancodeFromName(name string) Scancode { _name := C.CString(name) - defer C.SDL_free(unsafe.Pointer(_name)) + defer C.free(unsafe.Pointer(_name)) return (Scancode)(C.SDL_GetScancodeFromName(_name)) } @@ -115,7 +115,7 @@ func GetKeyName(code Keycode) string { // (https://wiki.libsdl.org/SDL_GetKeyFromName) func GetKeyFromName(name string) Keycode { _name := C.CString(name) - defer C.SDL_free(unsafe.Pointer(_name)) + defer C.free(unsafe.Pointer(_name)) return (Keycode)(C.SDL_GetKeyFromName(_name)) } diff --git a/sdl/loadso.go b/sdl/loadso.go index ded85926..f58b3cb2 100644 --- a/sdl/loadso.go +++ b/sdl/loadso.go @@ -11,7 +11,7 @@ type SharedObject uintptr // (https://wiki.libsdl.org/SDL_LoadObject) func LoadObject(sofile string) SharedObject { _sofile := C.CString(sofile) - defer C.SDL_free(unsafe.Pointer(_sofile)) + defer C.free(unsafe.Pointer(_sofile)) return (SharedObject)(C.SDL_LoadObject(_sofile)) } @@ -19,7 +19,7 @@ func LoadObject(sofile string) SharedObject { // (https://wiki.libsdl.org/SDL_LoadFunction) func (handle SharedObject) LoadFunction(name string) unsafe.Pointer { _name := C.CString(name) - defer C.SDL_free(unsafe.Pointer(_name)) + defer C.free(unsafe.Pointer(_name)) return (unsafe.Pointer)(C.SDL_LoadFunction((unsafe.Pointer)(handle), _name)) } diff --git a/sdl/log.go b/sdl/log.go index e42c03f3..1c461c85 100644 --- a/sdl/log.go +++ b/sdl/log.go @@ -135,7 +135,7 @@ func Log(str string, args ...interface{}) { str = fmt.Sprintf(str, args...) cstr := C.CString(str) - defer C.SDL_free(unsafe.Pointer(cstr)) + defer C.free(unsafe.Pointer(cstr)) C._SDL_Log(cstr) } @@ -146,7 +146,7 @@ func LogVerbose(category LogCategory, str string, args ...interface{}) { str = fmt.Sprintf(str, args...) cstr := C.CString(str) - defer C.SDL_free(unsafe.Pointer(cstr)) + defer C.free(unsafe.Pointer(cstr)) C._SDL_LogVerbose(C.int(category), cstr) } @@ -157,7 +157,7 @@ func LogDebug(category LogCategory, str string, args ...interface{}) { str = fmt.Sprintf(str, args...) cstr := C.CString(str) - defer C.SDL_free(unsafe.Pointer(cstr)) + defer C.free(unsafe.Pointer(cstr)) C._SDL_LogDebug(C.int(category), cstr) } @@ -168,7 +168,7 @@ func LogInfo(category LogCategory, str string, args ...interface{}) { str = fmt.Sprintf(str, args...) cstr := C.CString(str) - defer C.SDL_free(unsafe.Pointer(cstr)) + defer C.free(unsafe.Pointer(cstr)) C._SDL_LogInfo(C.int(category), cstr) } @@ -179,7 +179,7 @@ func LogWarn(category LogCategory, str string, args ...interface{}) { str = fmt.Sprintf(str, args...) cstr := C.CString(str) - defer C.SDL_free(unsafe.Pointer(cstr)) + defer C.free(unsafe.Pointer(cstr)) C._SDL_LogWarn(C.int(category), cstr) } @@ -190,7 +190,7 @@ func LogError(category LogCategory, str string, args ...interface{}) { str = fmt.Sprintf(str, args...) cstr := C.CString(str) - defer C.SDL_free(unsafe.Pointer(cstr)) + defer C.free(unsafe.Pointer(cstr)) C._SDL_LogError(C.int(category), cstr) } @@ -201,7 +201,7 @@ func LogCritical(category LogCategory, str string, args ...interface{}) { str = fmt.Sprintf(str, args...) cstr := C.CString(str) - defer C.SDL_free(unsafe.Pointer(cstr)) + defer C.free(unsafe.Pointer(cstr)) C._SDL_LogCritical(C.int(category), cstr) } @@ -212,7 +212,7 @@ func LogMessage(category LogCategory, pri LogPriority, str string, args ...inter str = fmt.Sprintf(str, args...) cstr := C.CString(str) - defer C.SDL_free(unsafe.Pointer(cstr)) + defer C.free(unsafe.Pointer(cstr)) C._SDL_LogMessage(C.int(category), C.SDL_LogPriority(pri), cstr) } diff --git a/sdl/rwops.go b/sdl/rwops.go index e2991c55..91e23b67 100644 --- a/sdl/rwops.go +++ b/sdl/rwops.go @@ -81,8 +81,8 @@ func (rwops *RWops) cptr() *C.SDL_RWops { func RWFromFile(file, mode string) *RWops { _file := C.CString(file) _mode := C.CString(mode) - defer C.SDL_free(unsafe.Pointer(_file)) - defer C.SDL_free(unsafe.Pointer(_mode)) + defer C.free(unsafe.Pointer(_file)) + defer C.free(unsafe.Pointer(_mode)) return (*RWops)(unsafe.Pointer(C.SDL_RWFromFile(_file, _mode))) } diff --git a/sdl/system_android.go b/sdl/system_android.go index b6ccee56..4d35a971 100644 --- a/sdl/system_android.go +++ b/sdl/system_android.go @@ -121,6 +121,6 @@ func IsAndroidTV() bool { // (https://wiki.libsdl.org/SDL_AndroidShowToast) func AndroidShowToast(message string, duration, gravity, xoffset, yoffset int) (err error) { _message := C.CString(message) - defer C.SDL_free(unsafe.Pointer(_message)) + defer C.free(unsafe.Pointer(_message)) return errorFromInt(int(C.SDL_AndroidShowToast(_message, C.int(duration), C.int(gravity), C.int(xoffset), C.int(yoffset)))) } diff --git a/sdl/video.go b/sdl/video.go index 813251a5..38f626de 100644 --- a/sdl/video.go +++ b/sdl/video.go @@ -948,9 +948,9 @@ func (window *Window) GetWindowOpacity() (opacity float32, err error) { // (https://wiki.libsdl.org/SDL_ShowSimpleMessageBox) func ShowSimpleMessageBox(flags MessageBoxFlags, title, message string, window *Window) error { _title := C.CString(title) - defer C.SDL_free(unsafe.Pointer(_title)) + defer C.free(unsafe.Pointer(_title)) _message := C.CString(message) - defer C.SDL_free(unsafe.Pointer(_message)) + defer C.free(unsafe.Pointer(_message)) return errorFromInt(int( C.SDL_ShowSimpleMessageBox(C.Uint32(flags), _title, _message, window.cptr()))) } @@ -959,15 +959,15 @@ func ShowSimpleMessageBox(flags MessageBoxFlags, title, message string, window * // (https://wiki.libsdl.org/SDL_ShowMessageBox) func ShowMessageBox(data *MessageBoxData) (buttonid int32, err error) { _title := C.CString(data.Title) - defer C.SDL_free(unsafe.Pointer(_title)) + defer C.free(unsafe.Pointer(_title)) _message := C.CString(data.Message) - defer C.SDL_free(unsafe.Pointer(_message)) + defer C.free(unsafe.Pointer(_message)) var cbuttons []C.SDL_MessageBoxButtonData var cbtntexts []*C.char defer func(texts []*C.char) { for _, t := range texts { - C.SDL_free(unsafe.Pointer(t)) + C.free(unsafe.Pointer(t)) } }(cbtntexts) diff --git a/sdl/vulkan.go b/sdl/vulkan.go index 2c27c27d..573ec9c9 100644 --- a/sdl/vulkan.go +++ b/sdl/vulkan.go @@ -97,7 +97,7 @@ func VulkanLoadLibrary(path string) error { ret = C.SDL_Vulkan_LoadLibrary(nil) } else { cpath := C.CString(path) - defer C.SDL_free(unsafe.Pointer(cpath)) + defer C.free(unsafe.Pointer(cpath)) ret = C.SDL_Vulkan_LoadLibrary(cpath) } if int(ret) == -1 {