Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mat_noprofile.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package gocv
#include "core.h"
*/
import "C"
import "errors"

// addMatToProfile does nothing if matprofile tag is not set.
func addMatToProfile(p C.Mat) {
Expand All @@ -20,6 +21,9 @@ func newMat(p C.Mat) Mat {

// Close the Mat object.
func (m *Mat) Close() error {
if m.p == nil {
return errors.New("duplicate Mat close")
}
C.Mat_Close(m.p)
m.p = nil
m.d = nil
Expand Down
3 changes: 3 additions & 0 deletions mat_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ func newMat(p C.Mat) Mat {

// Close the Mat object.
func (m *Mat) Close() error {
if m.p == nil {
return errors.New("duplicate Mat close")
}
// NOTE: The pointer must be removed from the profile before it is deleted to
// avoid a data race.
MatProfile.Remove(m.p)
Expand Down