From c9e6288649ba36ff887f52fb62d4cd557fa9ef34 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Tue, 23 Sep 2008 09:52:45 +0000 Subject: [PATCH] Fixed every (hopefully) CID cases of delete where delete[] should have been used. CID 122, 123, 124, 125, 126, 127, 128, 129, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 142, 143, 144, 147, 148, 149, 150 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27703 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/print/drivers/pcl6/PCL6.cpp | 2 +- src/add-ons/print/drivers/pdf/source/Mask.cpp | 2 +- src/add-ons/print/drivers/pdf/source/Report.cpp | 2 +- src/apps/packageinstaller/PackageItem.cpp | 12 ++++-------- src/apps/showimage/Filter.cpp | 4 ++-- src/bin/hey.cpp | 2 +- src/kits/mail/ProtocolConfigView.cpp | 2 +- src/kits/network/libnetapi/NetBuffer.cpp | 2 +- src/libs/print/libprint/HalftoneView.cpp | 2 +- src/libs/print/libprint/PrintJobReader.cpp | 2 +- src/preferences/keymap/KeymapWindow.cpp | 10 +++++----- 11 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/add-ons/print/drivers/pcl6/PCL6.cpp b/src/add-ons/print/drivers/pcl6/PCL6.cpp index 323ae7e585..09b8509395 100644 --- a/src/add-ons/print/drivers/pcl6/PCL6.cpp +++ b/src/add-ons/print/drivers/pcl6/PCL6.cpp @@ -298,7 +298,7 @@ void PCL6Driver::rasterGraphics( uchar *outBuffer = new uchar[dataSize]; pack_bits(outBuffer, buffer, bufferSize); fWriter->Append(outBuffer, dataSize); - delete outBuffer; + delete[] outBuffer; return; } else if (compressionMethod == PCL6Writer::kDeltaRowCompression) { // use delta row compression diff --git a/src/add-ons/print/drivers/pdf/source/Mask.cpp b/src/add-ons/print/drivers/pdf/source/Mask.cpp index b3438c7159..12374fdb22 100644 --- a/src/add-ons/print/drivers/pdf/source/Mask.cpp +++ b/src/add-ons/print/drivers/pdf/source/Mask.cpp @@ -125,7 +125,7 @@ bool Mask::Equals(CIDescription* description) const { if (buffer == NULL) return false; bool ok = file.Read(buffer, Length()) == Length() && memcmp(desc->Mask(), buffer, Length()) == 0; - delete buffer; + delete[] buffer; return ok; } } diff --git a/src/add-ons/print/drivers/pdf/source/Report.cpp b/src/add-ons/print/drivers/pdf/source/Report.cpp index 2bd6b3049a..93adf8db13 100644 --- a/src/add-ons/print/drivers/pdf/source/Report.cpp +++ b/src/add-ons/print/drivers/pdf/source/Report.cpp @@ -78,7 +78,7 @@ void Report::Add(kind kind, int32 page, const char* fmt, ...) { #endif vsprintf(b, fmt, list); AddItem(new ReportRecord(kind, page, "", b)); - delete b; + delete[] b; va_end(list); } } diff --git a/src/apps/packageinstaller/PackageItem.cpp b/src/apps/packageinstaller/PackageItem.cpp index 0a2c46ed1c..0fcfbfc7ed 100644 --- a/src/apps/packageinstaller/PackageItem.cpp +++ b/src/apps/packageinstaller/PackageItem.cpp @@ -293,10 +293,8 @@ PkgDirectory::_HandleAttributes(BPath *destination, BNode *node, break; } - if (attrData) - delete attrData; - if (temp) - delete temp; + delete[] attrData; + delete[] temp; } return ret; @@ -612,10 +610,8 @@ PkgFile::WriteToPath(const char *path, BPath *final) break; } - if (attrData) - delete attrData; - if (temp) - delete temp; + delete[] attrData; + delete[] temp; } if (final) { diff --git a/src/apps/showimage/Filter.cpp b/src/apps/showimage/Filter.cpp index ded6dcf609..d47b15378c 100644 --- a/src/apps/showimage/Filter.cpp +++ b/src/apps/showimage/Filter.cpp @@ -703,7 +703,7 @@ Scaler::DownScaleBilinear(intType fromRow, int32 toRow) } } - delete columnData; + delete[] columnData; } // Flyod-Steinberg Dithering @@ -877,7 +877,7 @@ Scaler::Dither(int32 fromRow, int32 toRow) } } - delete columnData0; + delete[] columnData0; } int32 diff --git a/src/bin/hey.cpp b/src/bin/hey.cpp index 7182dec6bd..bc81553439 100644 --- a/src/bin/hey.cpp +++ b/src/bin/hey.cpp @@ -380,7 +380,7 @@ Hey(BMessenger* target, const char* arg, BMessage* reply) int32 argx = 0; status_t ret = Hey(target, (char **)argv.Items(), &argx, argv.CountItems()-1, reply); // This used to be "return Hey(...);"---so tokens wasn't delete'd. -- pfolk@uni.uiuc.edu 1999-11-03 - delete tokens; + delete[] tokens; return ret; } diff --git a/src/kits/mail/ProtocolConfigView.cpp b/src/kits/mail/ProtocolConfigView.cpp index 228874285e..26960f2395 100644 --- a/src/kits/mail/ProtocolConfigView.cpp +++ b/src/kits/mail/ProtocolConfigView.cpp @@ -155,7 +155,7 @@ void BMailProtocolConfigView::SetTo(BMessage *archive) { if (password) { SetTextControl(this,"pass",password); - delete password; + delete[] password; } else SetTextControl(this,"pass",archive->FindString("password")); diff --git a/src/kits/network/libnetapi/NetBuffer.cpp b/src/kits/network/libnetapi/NetBuffer.cpp index 003a2e1dfe..fb69c97462 100644 --- a/src/kits/network/libnetapi/NetBuffer.cpp +++ b/src/kits/network/libnetapi/NetBuffer.cpp @@ -371,7 +371,7 @@ status_t BNetBuffer::AppendMessage( const BMessage& Msg ) result = dpush( B_MESSAGE_TYPE, msgLen, msgData ); } - delete msgData; + delete[] msgData; return result; } diff --git a/src/libs/print/libprint/HalftoneView.cpp b/src/libs/print/libprint/HalftoneView.cpp index 589166f2a2..fbb8ca2ab4 100644 --- a/src/libs/print/libprint/HalftoneView.cpp +++ b/src/libs/print/libprint/HalftoneView.cpp @@ -117,7 +117,7 @@ void HalftonePreviewView::preview(float gamma, float min, Halftone::DitherType d dstRow += preview.BytesPerRow(); } - delete buffer; + delete[] buffer; SetViewBitmap(&preview); Invalidate(); diff --git a/src/libs/print/libprint/PrintJobReader.cpp b/src/libs/print/libprint/PrintJobReader.cpp index 04bd665733..d3c67c6a73 100644 --- a/src/libs/print/libprint/PrintJobReader.cpp +++ b/src/libs/print/libprint/PrintJobReader.cpp @@ -167,7 +167,7 @@ void PrintJobReader::BuildPageIndex() fJobFile.Seek(next_page, SEEK_SET); } else { fNumberOfPages = 0; - delete fPageIndex; + delete[] fPageIndex; fPageIndex = NULL; return; } diff --git a/src/preferences/keymap/KeymapWindow.cpp b/src/preferences/keymap/KeymapWindow.cpp index a05184d1a5..4cdf29391e 100644 --- a/src/preferences/keymap/KeymapWindow.cpp +++ b/src/preferences/keymap/KeymapWindow.cpp @@ -1437,7 +1437,7 @@ MapView::_DrawKey(uint32 keyCode) if (str) { bool hasGlyphs; if (deadKey > 0) { - delete str; + delete[] str; switch (deadKey) { case 1: str = strdup("'"); break; case 2: str = strdup("`"); break; @@ -1461,7 +1461,7 @@ MapView::_DrawKey(uint32 keyCode) } DrawString(str, point); } - delete str; + delete[] str; } } @@ -1570,7 +1570,7 @@ MapView::MessageReceived(BMessage *msg) fTextView->FakeKeyDown(str, numBytes); } } - delete str; + delete[] str; } } break; @@ -1611,7 +1611,7 @@ MapView::MouseDown(BPoint point) fCurrentMap->GetChars(fCurrentMouseKey, fOldKeyInfo.modifiers, fActiveDeadKey, &str, &numBytes); if (numBytes > 0) { fTextView->FakeKeyDown(str, numBytes); - delete str; + delete[] str; } SetTracking(true); SetMouseEventMask(B_POINTER_EVENTS, @@ -1649,7 +1649,7 @@ MapView::MouseMoved(BPoint point, uint32 transit, const BMessage *msg) fCurrentMap->GetChars(fCurrentMouseKey, fOldKeyInfo.modifiers, fActiveDeadKey, &str, &numBytes); if (numBytes > 0) { fTextView->FakeKeyDown(str, numBytes); - delete str; + delete[] str; } break; }