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

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

Issue 232323002: Revert of remove sprintf (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 8 months 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
« no previous file with comments | « platform_tools/android/launcher/skia_launcher.cpp ('k') | no next file » | 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 2013 Google Inc. 3 * Copyright 2013 Google Inc.
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 #include "SkTLS.h" 9 #include "SkTLS.h"
10 #include "SkTypes.h" 10 #include "SkTypes.h"
11 #include "SkError.h" 11 #include "SkError.h"
12 #include "SkErrorInternals.h" 12 #include "SkErrorInternals.h"
13 13
14 #include <stdio.h> 14 #include <stdio.h>
15 #include <stdarg.h> 15 #include <stdarg.h>
16 16
17 #ifdef SK_BUILD_FOR_WIN
18 #define snprintf _snprintf
19 #endif
20
21 namespace { 17 namespace {
22 void *CreateThreadError() { 18 void *CreateThreadError() {
23 return SkNEW_ARGS(SkError, (kNoError_SkError)); 19 return SkNEW_ARGS(SkError, (kNoError_SkError));
24 } 20 }
25 void DeleteThreadError(void* v) { 21 void DeleteThreadError(void* v) {
26 SkDELETE(reinterpret_cast<SkError*>(v)); 22 SkDELETE(reinterpret_cast<SkError*>(v));
27 } 23 }
28 #define THREAD_ERROR \ 24 #define THREAD_ERROR \
29 (*reinterpret_cast<SkError*>(SkTLS::Get(CreateThreadError, DeleteThreadE rror))) 25 (*reinterpret_cast<SkError*>(SkTLS::Get(CreateThreadError, DeleteThreadE rror)))
30 26
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 error_name = "Out Of Memory"; 122 error_name = "Out Of Memory";
127 break; 123 break;
128 case kParseError_SkError: 124 case kParseError_SkError:
129 error_name = "Parse Error"; 125 error_name = "Parse Error";
130 break; 126 break;
131 default: 127 default:
132 error_name = "Unknown error"; 128 error_name = "Unknown error";
133 break; 129 break;
134 } 130 }
135 131
136 snprintf(str, ERROR_STRING_LENGTH, "%s: ", error_name); 132 sprintf( str, "%s: ", error_name );
137 int string_left = SkToInt(ERROR_STRING_LENGTH - strlen(str)); 133 int string_left = SkToInt(ERROR_STRING_LENGTH - strlen(str));
138 str += strlen(str); 134 str += strlen(str);
139 135
140 va_start( args, fmt ); 136 va_start( args, fmt );
141 vsnprintf( str, string_left, fmt, args ); 137 vsnprintf( str, string_left, fmt, args );
142 va_end( args ); 138 va_end( args );
143 SkErrorCallbackFunction fn = THREAD_ERROR_CALLBACK; 139 SkErrorCallbackFunction fn = THREAD_ERROR_CALLBACK;
144 if (fn && code != kNoError_SkError) { 140 if (fn && code != kNoError_SkError) {
145 fn(code, THREAD_ERROR_CONTEXT); 141 fn(code, THREAD_ERROR_CONTEXT);
146 } 142 }
147 } 143 }
OLDNEW
« no previous file with comments | « platform_tools/android/launcher/skia_launcher.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698