Menu

Improve resource leak checking

2020-05-31
2020-06-01
  • orbitcowboy

    orbitcowboy - 2020-05-31

    I try to improve resource leak checking of wxWidgets code.

    For example: wxGrid::GetCellRenderer() returns a pointer that must be called after its usage with wxGridCellRenderer::DecRef() to release internally allocated resources.

    Example code:
    Here Cppcheck should not produce a warning, because the resource is deallocated correctly, but it does.

    void NoLeak(const wxGrid &grid)
    {
        wxGridCellRenderer *renderer = grid.GetCellRenderer(0, 0);
        renderer->DecRef(); // << False positive: resource leak
    }
    

    Library configuration

      <resource>
        <alloc init="false">wxGrid::GetCellRenderer</alloc>
        <dealloc>wxGridCellRenderer::DecRef</dealloc>
      </resource>
    

    Is there something wrong with the dealloc configuration?

     
  • Daniel Marjamäki

    At the moment.. the dealloc function is supposed to take the allocated memory as argument. So sorry.. this is probably out of scope for now.

     
  • Daniel Marjamäki

    Feel free to open a ticket.

    I am not personally very interested to improve the leaks checking. But if anybody else wants to do it then I would welcome that.

     
    • orbitcowboy

      orbitcowboy - 2020-06-01

      Ok, thanks. I'll create a ticket.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.