From 97eb33f130349db5e01a4b85e89dd1da81460345 Mon Sep 17 00:00:00 2001 From: Alan King Date: Thu, 5 Oct 2023 16:19:20 -0400 Subject: [PATCH] [#6672] Fix struct clearing for getRescQuota API --- lib/api/include/irods/apiTable.hpp | 2 +- lib/core/include/irods/rcMisc.h | 4 ++++ lib/core/src/rcMisc.cpp | 26 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/api/include/irods/apiTable.hpp b/lib/api/include/irods/apiTable.hpp index 1f832f8861..ba98d13147 100644 --- a/lib/api/include/irods/apiTable.hpp +++ b/lib/api/include/irods/apiTable.hpp @@ -1121,7 +1121,7 @@ static irods::apidef_t client_api_table_inp[] = { GET_RESC_QUOTA_AN, RODS_API_VERSION, REMOTE_USER_AUTH, REMOTE_USER_AUTH, "getRescQuotaInp_PI", 0, "rescQuota_PI", 0, boost::any(std::function(RS_GET_RESC_QUOTA)), - "api_get_resc_quota", irods::clearInStruct_noop, clearDataObjInfo, + "api_get_resc_quota", clearRescQuotaInp, clearRescQuota, (funcPtr)CALL_GETRESCQUOTAINP_RESCQUOTAOUT }, { diff --git a/lib/core/include/irods/rcMisc.h b/lib/core/include/irods/rcMisc.h index dfc3f60e0f..145a94608e 100644 --- a/lib/core/include/irods/rcMisc.h +++ b/lib/core/include/irods/rcMisc.h @@ -65,6 +65,10 @@ void clearBytesBuffer(void* _p); void clearSwitchUserInput(void* _p); +void clearRescQuota(void* _p); + +void clearRescQuotaInp(void* _p); + // clang-format off __attribute__((deprecated("SimpleQuery is deprecated. Use GenQuery or SpecificQuery instead."))) void clearSimpleQueryOut(void* _p); diff --git a/lib/core/src/rcMisc.cpp b/lib/core/src/rcMisc.cpp index 4223eb639d..8cb15d287e 100644 --- a/lib/core/src/rcMisc.cpp +++ b/lib/core/src/rcMisc.cpp @@ -1773,6 +1773,32 @@ freeAllRescQuota( rescQuota_t *rescQuotaHead ) { return 0; } +void clearRescQuotaInp(void* _p) +{ + if (!_p) { + return; + } + + auto* q = static_cast(_p); + + clearKeyVal(&q->condInput); + + std::memset(q, 0, sizeof(getRescQuotaInp)); +} // clearRescQuotaInp + +void clearRescQuota(void* _p) +{ + if (!_p) { + return; + } + + auto* q = static_cast(_p); + + freeAllRescQuota(q->next); + + std::memset(q, 0, sizeof(rescQuota)); +} // clearRescQuota + int parseMultiStr( char *strInput, strArray_t *strArray ) { char *startPtr, *endPtr;