aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkTypes.h
diff options
context:
space:
mode:
authorGravatar mtklein@google.com <mtklein@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-20 14:31:45 +0000
committerGravatar mtklein@google.com <mtklein@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-20 14:31:45 +0000
commit519f9677a41239808f41a7c13ef1f6e05eb1ed50 (patch)
treea7a1acf5fc2c9d8c2390c48bc1a604628ff513e5 /include/core/SkTypes.h
parentf91e3d4f54de9976b6538decadd977b19e49eadd (diff)
Add sk_calloc. Remove SkMemory_stdlib, which seems unused.
I'm seeing basically no difference between malloc + bzero and calloc on my desktop, but on a Galaxy Nexus calloc is never slower, and significantly faster once the allocation size becomes large, both for allocation and for _reading_. BUG=skia:1662 R=reed@google.com Review URL: https://codereview.chromium.org/24251008 git-svn-id: http://skia.googlecode.com/svn/trunk@11414 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkTypes.h')
-rw-r--r--include/core/SkTypes.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index 039369119e..f2245184e6 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -49,7 +49,7 @@ enum {
};
/** Return a block of memory (at least 4-byte aligned) of at least the
specified size. If the requested memory cannot be returned, either
- return null (if SK_MALLOC_TEMP bit is clear) or call sk_throw()
+ return null (if SK_MALLOC_TEMP bit is clear) or throw an exception
(if SK_MALLOC_TEMP bit is set). To free the memory, call sk_free().
*/
SK_API extern void* sk_malloc_flags(size_t size, unsigned flags);
@@ -64,6 +64,14 @@ SK_API extern void* sk_realloc_throw(void* buffer, size_t size);
*/
SK_API extern void sk_free(void*);
+/** Much like calloc: returns a pointer to at least size zero bytes, or NULL on failure.
+ */
+SK_API extern void* sk_calloc(size_t size);
+
+/** Same as sk_calloc, but throws an exception instead of returning NULL on failure.
+ */
+SK_API extern void* sk_calloc_throw(size_t size);
+
// bzero is safer than memset, but we can't rely on it, so... sk_bzero()
static inline void sk_bzero(void* buffer, size_t size) {
memset(buffer, 0, size);