Fix a warning in recent versions of Clang

Clang will soon start emitting warnings for mismatch uses of new and
delete. In testing this upcoming feature of Clang, I found a
mismatched new/delete pair in matplotlib. I've applied the following
patch in my local tree, but I see that the problem still exists in
trunk.

The problem here is that the constructor for
ExtensionClassMethodsTable() is allocating an array of
m_methods_table, so it should be deallocated with delete[].

If this is OK for trunk, could someone apply this patch, please?

Thanks. Diego.

--- a/lib/matplotlib/src/CXX/Python2/ExtensionType.hxx
+++ b/lib/matplotlib/src/CXX/Python2/ExtensionType.hxx
@@ -125,7 +125,7 @@ namespace Py

         ~ExtensionClassMethodsTable()
         {
- delete m_methods_table;
+ delete[] m_methods_table;
         }

         // check that all methods added are unique

Diego,

Thank you for looking in to this.

What version of the source are you working off of? The location of those headers was recently moved and they no longer exist on master.

I have opened a PR with this patch (https://github.com/matplotlib/matplotlib/pull/4431) and it should go in for the color-overhaul/2.0 release.

If you subscribe to the devel list your emails will not need to be moderated.

Tom

···

On Fri, May 15, 2015 at 7:44 AM Diego Novillo <dnovillo@…624…> wrote:

Clang will soon start emitting warnings for mismatch uses of new and

delete. In testing this upcoming feature of Clang, I found a

mismatched new/delete pair in matplotlib. I’ve applied the following

patch in my local tree, but I see that the problem still exists in

trunk.

The problem here is that the constructor for

ExtensionClassMethodsTable() is allocating an array of

m_methods_table, so it should be deallocated with delete.

If this is OK for trunk, could someone apply this patch, please?

Thanks. Diego.

— a/lib/matplotlib/src/CXX/Python2/ExtensionType.hxx

+++ b/lib/matplotlib/src/CXX/Python2/ExtensionType.hxx

@@ -125,7 +125,7 @@ namespace Py

     ~ExtensionClassMethodsTable()

     {
  •        delete m_methods_table;
    
  •        delete[] m_methods_table;
    
       }
    
    
    
       // check that all methods added are unique
    

One dashboard for servers and applications across Physical-Virtual-Cloud

Widest out-of-the-box monitoring support with 50+ applications

Performance metrics, stats and reports that give you Actionable Insights

Deep dive visibility with transaction tracing using APM Insight.

http://ad.doubleclick.net/ddm/clk/290420510;117567292;y


Matplotlib-devel mailing list

Matplotlib-devel@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

I was looking at the file in trunk, but the patch is on an older
version (1.3.0).

Thanks. Diego.

···

On Fri, May 15, 2015 at 7:59 AM, Thomas Caswell <tcaswell@...149...> wrote:

What version of the source are you working off of? The location of those
headers was recently moved and they no longer exist on master.