diff --git a/src/msgPrintControl.cpp b/src/msgPrintControl.cpp index 990b29a..a950d3f 100644 --- a/src/msgPrintControl.cpp +++ b/src/msgPrintControl.cpp @@ -5,17 +5,13 @@ msgPrintControlKey::msgPrintControlKey(char *controller, int axisNo, const char *functionName, int line, - size_t maxRepetitions) { - controller_ = controller; - axisNo_ = axisNo; - line_ = line; - functionName_ = functionName; - maxRepetitions_ = maxRepetitions; -} + size_t maxRepetitions) + : controller_(controller), axisNo_(axisNo), functionName_(functionName), + line_(line), maxRepetitions_(maxRepetitions) {} void msgPrintControlKey::format(char *buffer, size_t bufferSize) { snprintf(buffer, bufferSize, "controller %s, axis %d, function %s, line %d", - controller_.c_str(), axisNo_, functionName_, line_); + controller_.c_str(), axisNo_, functionName_.c_str(), line_); } // ============================================================================= @@ -78,8 +74,8 @@ bool msgPrintControl::shouldBePrinted(msgPrintControlKey &key, bool wantToPrint, pasynUser, ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line %d\nError " "associated with key \"%s\" has been resolved.\n", - key.controller_.c_str(), key.axisNo_, key.functionName_, - key.line_, formattedKey); + key.controller_.c_str(), key.axisNo_, + key.functionName_.c_str(), key.line_, formattedKey); } map_[key] = 0; } @@ -107,7 +103,7 @@ void msgPrintControl::resetCount(msgPrintControlKey &key, asynUser *pasynUser) { "Controller \"%s\", axis %d => %s, line %d\nError " "associated with key \"%s\" has been resolved.\n", key.controller_.c_str(), key.axisNo_, - key.functionName_, key.line_, formattedKey); + key.functionName_.c_str(), key.line_, formattedKey); } map_[key] = 0; } diff --git a/src/msgPrintControl.h b/src/msgPrintControl.h index 32e4991..9d66957 100644 --- a/src/msgPrintControl.h +++ b/src/msgPrintControl.h @@ -23,7 +23,7 @@ class HIDDEN msgPrintControlKey { // -1 indicates a non-axis specific message int axisNo_; - const char *functionName_; + std::string functionName_; int line_; /** @@ -38,7 +38,7 @@ class HIDDEN msgPrintControlKey { bool operator==(const msgPrintControlKey &other) const { return axisNo_ == other.axisNo_ && line_ == other.line_ && - strcmp(functionName_, other.functionName_) == 0 && + functionName_ == other.functionName_ && controller_ == other.controller_; } @@ -55,7 +55,7 @@ template <> struct hash { // Combine the hashes of the members (x and y) size_t h1 = std::hash{}(obj.controller_); size_t h2 = hash{}(obj.axisNo_); - size_t h3 = std::hash{}(obj.functionName_); + size_t h3 = std::hash{}(obj.functionName_); size_t h4 = hash{}(obj.line_); // Combine the hashes (simple XOR and shifting technique) return h1 ^ (h2 << 1) ^ (h3 << 2) ^ (h4 << 3);