aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar junov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-12-14 20:12:51 +0000
committerGravatar junov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-12-14 20:12:51 +0000
commitd4a1567c179311a457283185a65f7a8aeb8fef80 (patch)
treecaff077063fa8754e911b33a7131bdd4239b62cb
parent54cae704151f78ff7829add3b53e41e34a373a6b (diff)
Replacing alloca call in SkTileGrid with SkAutoSMalloc
Review URL: https://codereview.appspot.com/6946054 git-svn-id: http://skia.googlecode.com/svn/trunk@6824 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--src/core/SkTileGrid.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/core/SkTileGrid.cpp b/src/core/SkTileGrid.cpp
index 6b089752d4..1a5e627341 100644
--- a/src/core/SkTileGrid.cpp
+++ b/src/core/SkTileGrid.cpp
@@ -8,10 +8,6 @@
#include "SkTileGrid.h"
-#if defined(SK_BUILD_FOR_WIN)
-#include <malloc.h> // for alloca
-#endif
-
SkTileGrid::SkTileGrid(int tileWidth, int tileHeight, int xTileCount, int yTileCount, SkTileGridNextDatumFunctionPtr nextDatumFunction)
{
fTileWidth = tileWidth;
@@ -77,8 +73,10 @@ void SkTileGrid::search(const SkIRect& query, SkTDArray<void*>* results) {
results->reset();
SkTDArray<int> curPositions;
curPositions.setCount(queryTileCount);
- SkTDArray<void *>** tileRange =
- (SkTDArray<void *>**)alloca(queryTileCount * sizeof(SkTDArray<void *>*));
+ // Note: Reserving space for 1024 tile pointers on the stack. If the malloc
+ // becomes a bottleneck, we may consider increasing that number.
+ SkAutoSTArray<1024, SkTDArray<void *>*> storage(queryTileCount);
+ SkTDArray<void *>** tileRange = storage.get();
int tile = 0;
for (int x = tileStartX; x < tileEndX; ++x) {
for (int y = tileStartY; y < tileEndY; ++y) {