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

Side by Side Diff: include/core/SkData.h

Issue 737093002: Stop overloading internal_dispose in SkTextBlob and SkData (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: ARGGGGGGHHHH Created 6 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
« no previous file with comments | « no previous file | include/core/SkTextBlob.h » ('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 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkData_DEFINED 8 #ifndef SkData_DEFINED
9 #define SkData_DEFINED 9 #define SkData_DEFINED
10 10
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 ReleaseProc fReleaseProc; 161 ReleaseProc fReleaseProc;
162 void* fReleaseProcContext; 162 void* fReleaseProcContext;
163 163
164 void* fPtr; 164 void* fPtr;
165 size_t fSize; 165 size_t fSize;
166 166
167 SkData(const void* ptr, size_t size, ReleaseProc, void* context); 167 SkData(const void* ptr, size_t size, ReleaseProc, void* context);
168 SkData(size_t size); // inplace new/delete 168 SkData(size_t size); // inplace new/delete
169 virtual ~SkData(); 169 virtual ~SkData();
170 170
171 virtual void internal_dispose() const SK_OVERRIDE; 171
172 // Objects of this type are sometimes created in a custom fashion using sk_m alloc_throw and
173 // therefore must be sk_freed. We overload new to also call sk_malloc_throw so that memory
174 // can be unconditionally released using sk_free in an overloaded delete. Ov erloading regular
175 // new means we must also overload placement new.
176 void* operator new(size_t size) { return sk_malloc_throw(size); }
177 void* operator new(size_t, void* p) { return p; }
178 void operator delete(void* p) { sk_free(p); }
172 179
173 // Called the first time someone calls NewEmpty to initialize the singleton. 180 // Called the first time someone calls NewEmpty to initialize the singleton.
174 friend SkData* sk_new_empty_data(); 181 friend SkData* sk_new_empty_data();
175 182
176 // shared internal factory 183 // shared internal factory
177 static SkData* PrivateNewWithCopy(const void* srcOrNull, size_t length); 184 static SkData* PrivateNewWithCopy(const void* srcOrNull, size_t length);
178 185
179 typedef SkRefCnt INHERITED; 186 typedef SkRefCnt INHERITED;
180 }; 187 };
181 188
182 /** Typedef of SkAutoTUnref<SkData> for automatically unref-ing a SkData. */ 189 /** Typedef of SkAutoTUnref<SkData> for automatically unref-ing a SkData. */
183 typedef SkAutoTUnref<SkData> SkAutoDataUnref; 190 typedef SkAutoTUnref<SkData> SkAutoDataUnref;
184 191
185 #endif 192 #endif
OLDNEW
« no previous file with comments | « no previous file | include/core/SkTextBlob.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698