diff --git a/src/add-ons/media/media-add-ons/mixer/MixerCore.cpp b/src/add-ons/media/media-add-ons/mixer/MixerCore.cpp index 4931f4560d..5af27a6d33 100644 --- a/src/add-ons/media/media-add-ons/mixer/MixerCore.cpp +++ b/src/add-ons/media/media-add-ons/mixer/MixerCore.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -520,8 +521,9 @@ MixerCore::_MixThread() uint64 bufferIndex = 0; #endif - RtList inputChanInfos[MAX_CHANNEL_TYPES]; - RtList mixChanInfos[fMixBufferChannelCount]; + typedef RtList chan_info_list; + chan_info_list inputChanInfos[MAX_CHANNEL_TYPES]; + BStackOrHeapArray mixChanInfos(fMixBufferChannelCount); // TODO: this does not support changing output channel count bigtime_t eventTime = timeBase; diff --git a/src/apps/fontdemo/FontDemoView.cpp b/src/apps/fontdemo/FontDemoView.cpp index af4205ed3d..ec1ab5498f 100644 --- a/src/apps/fontdemo/FontDemoView.cpp +++ b/src/apps/fontdemo/FontDemoView.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "messages.h" @@ -99,7 +100,7 @@ FontDemoView::_DrawView(BView* view) view->SetFont(&fFont, B_FONT_ALL); const size_t size = fString.CountChars(); - BRect boundBoxes[size]; + BStackOrHeapArray boundBoxes(size); if (OutLineLevel()) fFont.GetGlyphShapes(fString, size, fShapes); @@ -456,4 +457,4 @@ FontDemoView::_NewBitmap(BRect rect) delete fBitmap; fBitmap = NULL; } -} \ No newline at end of file +} diff --git a/src/apps/icon-o-matic/shape/PathManipulator.cpp b/src/apps/icon-o-matic/shape/PathManipulator.cpp index fa30575a61..4e50c1169d 100644 --- a/src/apps/icon-o-matic/shape/PathManipulator.cpp +++ b/src/apps/icon-o-matic/shape/PathManipulator.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include "cursors.h" @@ -1703,7 +1704,7 @@ PathManipulator::_Nudge(BPoint direction) int32 count = fromSelection ? fSelection->CountItems() : fPath->CountPoints(); int32 indices[count]; - control_point points[count]; + BStackOrHeapArray points(count); // init indices and points for (int32 i = 0; i < count; i++) { diff --git a/src/apps/soundrecorder/VUView.cpp b/src/apps/soundrecorder/VUView.cpp index c90afc5e2f..2f6112be63 100644 --- a/src/apps/soundrecorder/VUView.cpp +++ b/src/apps/soundrecorder/VUView.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include "DrawingTidbits.h" @@ -108,7 +109,7 @@ VUView::_RenderLaunch(void *data) void VUView::_RenderLoop() { - rgb_color levels[fLevelCount][2]; + BStackOrHeapArray levels(fLevelCount); for (int32 i = 0; i < fLevelCount; i++) { levels[i][0] = levels[i][1] = back_color; diff --git a/src/apps/terminal/BasicTerminalBuffer.cpp b/src/apps/terminal/BasicTerminalBuffer.cpp index dfbb54e28d..0006066b50 100644 --- a/src/apps/terminal/BasicTerminalBuffer.cpp +++ b/src/apps/terminal/BasicTerminalBuffer.cpp @@ -18,6 +18,7 @@ #include +#include #include #include "TermConst.h" @@ -537,7 +538,7 @@ BasicTerminalBuffer::Find(const char* _pattern, const TermPos& start, int32 patternByteLen = strlen(_pattern); // convert pattern to UTF8Char array - UTF8Char pattern[patternByteLen]; + BStackOrHeapArray pattern(patternByteLen); int32 patternLen = 0; while (*_pattern != '\0') { int32 charLen = UTF8Char::ByteCount(*_pattern); diff --git a/src/kits/app/ServerLink.cpp b/src/kits/app/ServerLink.cpp index ea7664abce..05ac105465 100644 --- a/src/kits/app/ServerLink.cpp +++ b/src/kits/app/ServerLink.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -96,11 +97,11 @@ ServerLink::ReadShape(BShape* shape) fReceiver->Read(&opCount, sizeof(int32)); fReceiver->Read(&ptCount, sizeof(int32)); - uint32 opList[opCount]; + BStackOrHeapArray opList(opCount); if (opCount > 0) fReceiver->Read(opList, opCount * sizeof(uint32)); - BPoint ptList[ptCount]; + BStackOrHeapArray ptList(ptCount); if (ptCount > 0) fReceiver->Read(ptList, ptCount * sizeof(BPoint)); diff --git a/src/kits/support/ArchivingManagers.cpp b/src/kits/support/ArchivingManagers.cpp index 3405b53b20..069b3392be 100644 --- a/src/kits/support/ArchivingManagers.cpp +++ b/src/kits/support/ArchivingManagers.cpp @@ -11,6 +11,8 @@ #include #include +#include + namespace BPrivate { namespace Archiving { @@ -163,7 +165,7 @@ BArchiveManager::ArchiverLeaving(const BArchiver* archiver, status_t err) if (archiver == fCreator && fError == B_OK) { // first, we must sort the objects into the order they were archived in typedef std::pair ArchivePair; - ArchivePair pairs[fTokenMap.size()]; + BStackOrHeapArray pairs(fTokenMap.size()); for(TokenMap::iterator it = fTokenMap.begin(), end = fTokenMap.end(); it != end; it++) { diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index 057df07912..8c0122ac22 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -1856,10 +1857,9 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) size = 0.0f; } - // TODO: don't use the stack for this - numStrings could be large - float widthArray[numStrings]; - int32 lengthArray[numStrings]; - char *stringArray[numStrings]; + BStackOrHeapArray widthArray(numStrings); + BStackOrHeapArray lengthArray(numStrings); + BStackOrHeapArray stringArray(numStrings); for (int32 i = 0; i < numStrings; i++) { // This version of ReadString allocates the strings, we free // them below @@ -1882,7 +1882,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) } fLink.StartMessage(B_OK); - fLink.Attach(widthArray, sizeof(widthArray)); + fLink.Attach(widthArray, numStrings * sizeof(float)); } else fLink.StartMessage(B_BAD_VALUE); @@ -2497,8 +2497,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) link.Read(&deltaArray[i]); } - // TODO: don't do this on the heap! (at least check the size before) - BRect rectArray[numStrings]; + BStackOrHeapArray rectArray(numStrings); ServerFont font; bool success = false; @@ -2513,7 +2512,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) if (font.GetBoundingBoxesForStrings(stringArray, lengthArray, numStrings, rectArray, mode, deltaArray) == B_OK) { fLink.StartMessage(B_OK); - fLink.Attach(rectArray, sizeof(rectArray)); + fLink.Attach(rectArray, numStrings * sizeof(BRect)); success = true; } } diff --git a/src/servers/app/drawing/DrawingEngine.cpp b/src/servers/app/drawing/DrawingEngine.cpp index 4ec70d7695..6ef0b85c73 100644 --- a/src/servers/app/drawing/DrawingEngine.cpp +++ b/src/servers/app/drawing/DrawingEngine.cpp @@ -10,7 +10,10 @@ #include "DrawingEngine.h" #include +#include + #include + #include #include @@ -469,7 +472,7 @@ DrawingEngine::CopyRegion(/*const*/ BRegion* region, int32 xOffset, // TODO: make this step unnecessary // (by using different stack impl inside node) - node nodes[count]; + BStackOrHeapArray nodes(count); for (int32 i= 0; i < count; i++) { nodes[i].init(region->RectAt(i), count); }