From 2a31d6a41167dc94217e3159e9a74a1af3690332 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Tue, 1 Dec 2020 16:20:32 -0500 Subject: [PATCH] rados: add a function for use as a finalizer for any opStep This utility function avoids having to have a custom finalizer for every op step. It calls the free() function to release any allocated C memory the step may have. Signed-off-by: John Mulligan --- rados/operation.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rados/operation.go b/rados/operation.go index 44e89f1..6b52e35 100644 --- a/rados/operation.go +++ b/rados/operation.go @@ -112,6 +112,12 @@ func (o *operation) update(kind opKind, ret C.int) error { } } +func opStepFinalizer(s opStep) { + if s != nil { + s.free() + } +} + // withoutUpdate can be embedded in a struct to help indicate // the type implements the opStep interface but has a no-op // update function.