VLDSetReportOptions not working as expected?

Feb 23, 2011 at 11:48 AM
Edited Feb 23, 2011 at 3:37 PM

I want to use this function to tell VLD to not write to any file. For that, i currently call the following line and it doesnt prevent the creation of and the writing to the file:

VLDSetReportOptions(VLD_OPT_REPORT_TO_DEBUGGER | ~VLD_OPT_REPORT_TO_FILE, NULL);

I assumed this mask i hand over only contains the debugger bit set, and the report to file bit removed. Both are not identical,
and there is no way to query the current mask. But anyways, i'm pretty sure my mask should work. I also tried only handing over the debugger flag.
As seen, the file parameter is also null. The odd thing here is, the code logic to handle the file param is also wrong. It seems to report "cannot open file"
when at the momentl. I dont want to see that if its not an error - and it is no error, since i validly gave it no file to work with?

 

PS: Also, documentation of VLDSetReportOptions() is slightly wrong, it begins with: "// VLDSetOptions - Update the report options via function call rather than INI file."
(function name being wrong)

Please help.

Kind regards,
cal

Feb 24, 2011 at 8:55 PM

Ok, i fixed it locally myself. For that i download the sources and tried to find the corresponding lines.

 

To fix both bugs go here:


void VisualLeakDetector::SetupReporting()
{
    WCHAR      bom = BOM; // Unicode byte-order mark.

    //Close the previous report file if needed.
    if ( m_reportfile )
    {
        fclose(m_reportfile);
    }
    else
    {
        return;
    }

the else return block is missing in the original code. It fixes the warning "couldnt open file" when given no file and also does not set up a default reportfile.

 

I'd like to get feedback on this, though.

 

 

Regards,

cal

 

Developer
Feb 28, 2011 at 8:34 PM

I wouldn't just return at the location you specify. If you look further down at the end of the function, there is code specifically put there to handle when m_reportfile is NULL. And it doesn't and shouldn't be made to silently return. At least report something.....