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 <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2020-12-01 16:20:32 -05:00 committed by mergify[bot]
parent f1934a5513
commit 2a31d6a411
1 changed files with 6 additions and 0 deletions

View File

@ -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 // withoutUpdate can be embedded in a struct to help indicate
// the type implements the opStep interface but has a no-op // the type implements the opStep interface but has a no-op
// update function. // update function.