From d5e05d428647c164080e38dabee94db52c8c4544 Mon Sep 17 00:00:00 2001 From: "mike@reedtribe.org" Date: Sun, 10 Apr 2011 00:44:32 +0000 Subject: [PATCH] balance sk_malloc with sk_free (instead of delete[]) in SkAutoUCS2 patch submitted by alean2...@gmail.com git-svn-id: http://skia.googlecode.com/svn/trunk@1094 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/core/SkString.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/core/SkString.cpp b/src/core/SkString.cpp index b8f99c7..8a1591a 100644 --- a/src/core/SkString.cpp +++ b/src/core/SkString.cpp @@ -612,23 +612,21 @@ void SkString::swap(SkString& other) ///////////////////////////////////////////////////////////////////////////////// -SkAutoUCS2::SkAutoUCS2(const char utf8[]) -{ +SkAutoUCS2::SkAutoUCS2(const char utf8[]) { size_t len = strlen(utf8); fUCS2 = (uint16_t*)sk_malloc_throw((len + 1) * sizeof(uint16_t)); uint16_t* dst = fUCS2; - for (;;) - { - SkUnichar uni = SkUTF8_NextUnichar(&utf8); + for (;;) { + SkUnichar uni = SkUTF8_NextUnichar(&utf8); *dst++ = SkToU16(uni); - if (uni == 0) + if (uni == 0) { break; + } } fCount = (int)(dst - fUCS2); } -SkAutoUCS2::~SkAutoUCS2() -{ - delete[] fUCS2; +SkAutoUCS2::~SkAutoUCS2() { + sk_free(fUCS2); } -- 2.7.4