aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/core/SkTemplates.h16
-rw-r--r--include/utils/win/SkTScopedComPtr.h5
2 files changed, 17 insertions, 4 deletions
diff --git a/include/core/SkTemplates.h b/include/core/SkTemplates.h
index 24705dbed0..566834cab3 100644
--- a/include/core/SkTemplates.h
+++ b/include/core/SkTemplates.h
@@ -295,11 +295,17 @@ private:
template <size_t N, typename T> class SK_API SkAutoSTMalloc : SkNoncopyable {
public:
+ SkAutoSTMalloc() {
+ fPtr = NULL;
+ }
+
SkAutoSTMalloc(size_t count) {
- if (count <= N) {
+ if (count > N) {
+ fPtr = (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW | SK_MALLOC_TEMP);
+ } else if (count) {
fPtr = fTStorage;
} else {
- fPtr = (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW | SK_MALLOC_TEMP);
+ fPtr = NULL;
}
}
@@ -314,10 +320,12 @@ public:
if (fPtr != fTStorage) {
sk_free(fPtr);
}
- if (count <= N) {
+ if (count > N) {
+ fPtr = (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW | SK_MALLOC_TEMP);
+ } else if (count) {
fPtr = fTStorage;
} else {
- fPtr = (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW | SK_MALLOC_TEMP);
+ fPtr = NULL;
}
}
diff --git a/include/utils/win/SkTScopedComPtr.h b/include/utils/win/SkTScopedComPtr.h
index 85c314a97a..fa64ac4803 100644
--- a/include/utils/win/SkTScopedComPtr.h
+++ b/include/utils/win/SkTScopedComPtr.h
@@ -19,6 +19,11 @@ private:
virtual ULONG STDMETHODCALLTYPE Release(void) = 0;
};
+template<typename T> T* SkRefComPtr(T* ptr) {
+ ptr->AddRef();
+ return ptr;
+}
+
template<typename T>
class SkTScopedComPtr : SkNoncopyable {
private: