Stop bench from leaking
authorbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 13 Aug 2012 22:10:05 +0000 (22:10 +0000)
committerbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 13 Aug 2012 22:10:05 +0000 (22:10 +0000)
Review URL: http://codereview.appspot.com/6465045/

git-svn-id: http://skia.googlecode.com/svn/trunk@5072 2bbb7eff-a529-9590-31e7-b0007b416f81

bench/TextBench.cpp
bench/benchmain.cpp

index 0bef92c..9334c33 100644 (file)
@@ -49,6 +49,7 @@ class TextBench : public SkBenchmark {
 public:
     TextBench(void* param, const char text[], int ps,
               SkColor color, FontQuality fq, bool doPos = false) : INHERITED(param) {
+        fPos = NULL;
         fFQ = fq;
         fDoPos = doPos;
         fText.set(text);
index 0ea48e9..73aa988 100644 (file)
@@ -374,6 +374,7 @@ static void determine_gpu_context_size(SkTDict<const char*>& defineDict,
         if (*contextHeight < dim.fY) {
             *contextHeight = dim.fY;
         }
+        bench->unref();
     }
 }
 
@@ -737,6 +738,8 @@ int main (int argc, char * const argv[]) {
     Iter iter(&defineDict);
     SkBenchmark* bench;
     while ((bench = iter.next()) != NULL) {
+        SkAutoTUnref<SkBenchmark> benchUnref(bench);
+
         SkIPoint dim = bench->getSize();
         if (dim.fX <= 0 || dim.fY <= 0) {
             continue;