Skip to content

Conversation

@briansorahan
Copy link
Contributor

Proposed API for #1

@briansorahan briansorahan mentioned this pull request Feb 23, 2017
Copy link

@kisielk kisielk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API looks good to me. A few comments about memory leakage.

midi_linux.go Outdated
if rc := C.snd_ctl_open(&ctl, name, 0); rc != 0 {
return nil, alsaMidiError(rc)
}
C.free(unsafe.Pointer(name))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will leak memory if rc != 0. Should probably use defer after the C.Cstring allocation.


func getDeviceDevices(ctl *C.snd_ctl_t, card C.int, device C.uint) ([]*Device, error) {
var info *C.snd_rawmidi_info_t
C.snd_rawmidi_info_malloc(&info)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably needs to be freed somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

midi_linux.go Outdated
return errors.Errorf("error opening device %d", result.error)
}
d.conn = result.midi
C.free(unsafe.Pointer(id))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will leak id if result.error is != 0. You should probably just use defer C.free right after the call to C.CString

@briansorahan
Copy link
Contributor Author

@kisielk thanks for the review. I'll take a look at implementing the same API on mac

@briansorahan briansorahan merged commit 4dfd805 into master Feb 24, 2017
@briansorahan briansorahan deleted the enumerate-devices branch February 24, 2017 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants