rdfhdt / hdt-cpp

HDT C++ Library and Tools
115 stars 65 forks source link

Mismatched new/delete #241

Closed donpellegrino closed 2 years ago

donpellegrino commented 2 years ago

There are a few cases where delete instead of delete[] is used.

src/hdt/BasicModifiableHDT.cpp:156:17: warning: assigning field to itself [-Wself-assign-field]
        this->fileName = fileName;
                       ^
src/static/sequence/wt_coder_huff.cpp:76:24: note: allocated with 'new[]' here
        uint *buffer = new uint[maxBuffer];
                       ^
src/static/sequence/wt_coder_huff.cpp:92:9: warning: 'delete' applied to a pointer that was allocated with 'new[]'; did
      you mean 'delete[]'? [-Wmismatched-new-delete]
        delete buffer;
        ^
              []
src/static/sequence/wt_coder_huff.cpp:89:24: note: allocated with 'new[]' here
        uint *buffer = new uint[maxBuffer];
                       ^
src/sequence/HuffmanSequence.cpp:90:5: warning: 'delete' applied to a pointer that was allocated with 'new[]'; did you
      mean 'delete[]'? [-Wmismatched-new-delete]
    delete encV;
    ^
          []
src/sequence/HuffmanSequence.cpp:83:23: note: allocated with 'new[]' here
        unsigned int *encV = new unsigned int[encEntries];
                             ^

It is not clear if these were definitely leaking memory, but they can probably be cleaned up pretty easily.