Commit 7bea86f9 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner

[2433] Avoid copy of the callbacks

When passing an argument to boost::bind by value, it was copied
(obviously, since it allowed removal of const). Add the const and use a
pointer to avoid the copy of possibly large object.
parent 1f011110
......@@ -170,15 +170,15 @@ checkNS(const Name& zone_name, const RRClass& zone_class,
// The following two are simple wrapper of checker callbacks so checkZone()
// can also remember any critical errors.
errorWrapper(const string& reason, ZoneCheckerCallbacks& callbacks,
errorWrapper(const string& reason, const ZoneCheckerCallbacks* callbacks,
bool* had_error) {
*had_error = true;
warnWrapper(const string& reason, ZoneCheckerCallbacks& callbacks) {
warnWrapper(const string& reason, const ZoneCheckerCallbacks* callbacks) {
......@@ -188,8 +188,8 @@ checkZone(const Name& zone_name, const RRClass& zone_class,
const ZoneCheckerCallbacks& callbacks) {
bool had_error = false;
ZoneCheckerCallbacks my_callbacks(
boost::bind(errorWrapper, _1, callbacks, &had_error),
boost::bind(warnWrapper, _1, callbacks));
boost::bind(errorWrapper, _1, &callbacks, &had_error),
boost::bind(warnWrapper, _1, &callbacks));
checkSOA(zone_name, zone_class, zone_rrsets, my_callbacks);
checkNS(zone_name, zone_class, zone_rrsets, my_callbacks);
......@@ -59,7 +59,7 @@ public:
/// thrown from the callback.
/// \param reason Textual representation of the reason for the error.
void error(const std::string& reason) {
void error(const std::string& reason) const {
if (!error_callback_.empty()) {
......@@ -71,7 +71,7 @@ public:
/// thrown from the callback.
/// \param reason Textual representation of the reason for the issue.
void warn(const std::string& reason) {
void warn(const std::string& reason) const {
if (!warn_callback_.empty())
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment