[bind10-dev] in order to build bind10-20120517 against log4cplus-1.1.0-rc5

JINMEI Tatuya / 神明達哉 jinmei at isc.org
Wed Jun 6 21:17:16 UTC 2012


At Wed, 6 Jun 2012 19:23:11 +0000,
John Lumby <jlumby at bluecatnetworks.com> wrote:

> Yes,  I think you are correct,    my patch is not good.    I am not sure what is the best correction.
> Maybe the method could allocate a new string() and cast it to tstring,  but I could not get that idea to work,
> and in any case it would then leak memory unless reclaimed.
> 
> I will see if I can find out the expected call usage for this method now that the log4cplus has changed it to return a ref.

On a closer look at the code, I guess the returned object can simply
be statically constructed:

const log4cplus::tstring&
LoggerLevelImpl::logLevelToString(log4cplus::LogLevel level) {
    Level bindlevel = convertToBindLevel(level);
    Severity& severity = bindlevel.severity;
    int& dbglevel = bindlevel.dbglevel;
    static const tstring debug_tstring("DEBUG");
    static const tstring empty_tstring;

    if ((severity == DEBUG) &&
        ((dbglevel >= MIN_DEBUG_LEVEL) && (dbglevel <= MAX_DEBUG_LEVEL))) {
        return (debug_tstring);
    }

    // Unknown, so return empty string for log4cplus to try other conversion
    // functions.
    return (empty_tstring);
}

In fact, they are essentially constants and especially in this
particular case there are only two possible cases.  So the cost of
holding these should be marginal.

---
JINMEI, Tatuya
Internet Systems Consortium, Inc.


More information about the bind10-dev mailing list