From cfcfbd4360cff1d7a0fb1332a6013cdc6270b381 Mon Sep 17 00:00:00 2001 From: ndrpnt <22328659+ndrpnt@users.noreply.github.com> Date: Thu, 21 Apr 2022 11:10:10 +0200 Subject: [PATCH] Make Free() return Go error instead of C error code --- clamav.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/clamav.go b/clamav.go index 98d440d..c08b2fa 100644 --- a/clamav.go +++ b/clamav.go @@ -176,8 +176,12 @@ func (c *Clamav) EngineGetNum(field EngineField) (uint64, error) { // Free the memory allocated to clamav instance, Free should be called // when the engine is no longer in use. -func (c *Clamav) Free() int { - return int(C.cl_engine_free((*C.struct_cl_engine)(c.engine))) +func (c *Clamav) Free() error { + ret := ErrorCode(C.cl_engine_free((*C.struct_cl_engine)(c.engine))) + if ret == CL_SUCCESS { + return nil + } + return Strerr(ret) } // ScanMapCB scans custom data