Skip to content

Commit

Permalink
Clear finalizers when Destroy() is called (refs #213)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinfx committed Jan 4, 2020
1 parent 4f53a66 commit e89be40
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions imagick/drawing_wand.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func (dw *DrawingWand) Destroy() {
dw.init.Do(func() {
dw.dw = C.DestroyDrawingWand(dw.dw)
relinquishMemory(unsafe.Pointer(dw.dw))
runtime.SetFinalizer(dw, nil)
dw.dw = nil

dw.DecreaseCount()
Expand Down
1 change: 1 addition & 0 deletions imagick/image_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func newImageInfo() *ImageInfo {
func (ii *ImageInfo) Destroy() {
if ii.info != nil {
C.DestroyImageInfo(ii.info)
runtime.SetFinalizer(ii, nil)
ii.info = nil
}
}
1 change: 1 addition & 0 deletions imagick/kernel_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func newKernelInfo(cki *C.KernelInfo) *KernelInfo {
func (ki *KernelInfo) Destroy() {
if ki.info != nil {
C.DestroyKernelInfo(ki.info)
runtime.SetFinalizer(ki, nil)
ki.info = nil
}
}
Expand Down
1 change: 1 addition & 0 deletions imagick/magick_wand.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func (mw *MagickWand) Destroy() {
mw.init.Do(func() {
mw.mw = C.DestroyMagickWand(mw.mw)
relinquishMemory(unsafe.Pointer(mw.mw))
runtime.SetFinalizer(mw, nil)
mw.mw = nil

mw.DecreaseCount()
Expand Down
1 change: 1 addition & 0 deletions imagick/pixel_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func (pi *PixelIterator) Destroy() {
pi.init.Do(func() {
pi.pi = C.DestroyPixelIterator(pi.pi)
relinquishMemory(unsafe.Pointer(pi.pi))
runtime.SetFinalizer(pi, nil)
pi.pi = nil

pi.DecreaseCount()
Expand Down
1 change: 1 addition & 0 deletions imagick/pixel_wand.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (pw *PixelWand) Destroy() {
pw.init.Do(func() {
pw.pw = C.DestroyPixelWand(pw.pw)
relinquishMemory(unsafe.Pointer(pw.pw))
runtime.SetFinalizer(pw, nil)
pw.pw = nil

pw.DecreaseCount()
Expand Down

0 comments on commit e89be40

Please sign in to comment.