From 178b83222380f7b7294cde66e66719c5d1c1363c Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 12 Oct 2018 17:37:39 +0200 Subject: [PATCH] funcs name only in c++, bug fix:slsdetectorusers not deleting multislsdetectorcommand object, bug fix: programfpga does not delete fpgasrc malloc if returning in failure --- slsDetectorSoftware/slsDetector/slsDetector.cpp | 4 ++++ slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp | 2 ++ slsSupportLib/include/sls_detector_funcs.h | 6 ++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index b756c7b24..07a994a58 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -5101,12 +5101,16 @@ int slsDetector::programFPGA(std::string fname) { if(fread(fpgasrc, sizeof(char), filesize, fp) != filesize){ std::cout << "Could not read rawbin file" << std::endl; setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); + if(fpgasrc != NULL) + free(fpgasrc); return FAIL; } if(fclose(fp)){ std::cout << "Could not close destination file after converting" << std::endl; setErrorMask((getErrorMask())|(PROGRAMMING_ERROR)); + if(fpgasrc != NULL) + free(fpgasrc); return FAIL; } unlink(destfname); // delete temporary file diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp b/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp index d0198f96d..9b60f3731 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorUsers.cpp @@ -21,6 +21,8 @@ slsDetectorUsers::slsDetectorUsers(int& ret, int id) : myDetector(0), myCmd(0){ slsDetectorUsers::~slsDetectorUsers() { if (myDetector) delete myDetector; + if (myCmd) + delete myCmd; } int slsDetectorUsers::getNumberOfDetectors() { diff --git a/slsSupportLib/include/sls_detector_funcs.h b/slsSupportLib/include/sls_detector_funcs.h index 46173eaec..1ed9f1192 100644 --- a/slsSupportLib/include/sls_detector_funcs.h +++ b/slsSupportLib/include/sls_detector_funcs.h @@ -1,4 +1,5 @@ #pragma once + /************************************************ * @file sls_detector_funcs.h * @short functions indices to call on server (detector/receiver) @@ -121,7 +122,7 @@ enum detFuncs{ NUM_REC_FUNCTIONS }; - +#ifdef __cplusplus static const char* getFunctionNameFromEnum(enum detFuncs func) { switch (func) { case F_EXEC_COMMAND: return "F_EXEC_COMMAND"; @@ -237,5 +238,6 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) { case NUM_REC_FUNCTIONS: return "NUM_REC_FUNCTIONS"; default: return "Unknown Function"; } -} +}; +#endif