Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: src/core/SkString.cpp

Issue 72603005: Guard against most unintentionally ephemeral SkAutoFoo instantiations. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: undo autoasciitolc Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/core/SkRasterClip.h ('k') | src/ports/SkFontHost_win.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkString.h" 10 #include "SkString.h"
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 other.validate(); 619 other.validate();
620 620
621 SkTSwap<Rec*>(fRec, other.fRec); 621 SkTSwap<Rec*>(fRec, other.fRec);
622 #ifdef SK_DEBUG 622 #ifdef SK_DEBUG
623 SkTSwap<const char*>(fStr, other.fStr); 623 SkTSwap<const char*>(fStr, other.fStr);
624 #endif 624 #endif
625 } 625 }
626 626
627 /////////////////////////////////////////////////////////////////////////////// 627 ///////////////////////////////////////////////////////////////////////////////
628 628
629 SkAutoUCS2::SkAutoUCS2(const char utf8[]) {
630 size_t len = strlen(utf8);
631 fUCS2 = (uint16_t*)sk_malloc_throw((len + 1) * sizeof(uint16_t));
632
633 uint16_t* dst = fUCS2;
634 for (;;) {
635 SkUnichar uni = SkUTF8_NextUnichar(&utf8);
636 *dst++ = SkToU16(uni);
637 if (uni == 0) {
638 break;
639 }
640 }
641 fCount = (int)(dst - fUCS2);
642 }
643
644 SkAutoUCS2::~SkAutoUCS2() {
645 sk_free(fUCS2);
646 }
647
648 ///////////////////////////////////////////////////////////////////////////////
649
650 SkString SkStringPrintf(const char* format, ...) { 629 SkString SkStringPrintf(const char* format, ...) {
651 SkString formattedOutput; 630 SkString formattedOutput;
652 char buffer[kBufferSize]; 631 char buffer[kBufferSize];
653 ARGS_TO_BUFFER(format, buffer, kBufferSize); 632 ARGS_TO_BUFFER(format, buffer, kBufferSize);
654 formattedOutput.set(buffer); 633 formattedOutput.set(buffer);
655 return formattedOutput; 634 return formattedOutput;
656 } 635 }
657 636
658 #undef VSNPRINTF 637 #undef VSNPRINTF
659 #undef SNPRINTF 638 #undef SNPRINTF
OLDNEW
« no previous file with comments | « src/core/SkRasterClip.h ('k') | src/ports/SkFontHost_win.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698