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

Unified Diff: include/core/SkTypes.h

Issue 24251008: Add sk_calloc. Remove SkMemory_stdlib, which seems unused. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: use sk_out_of_memory Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gyp/tests.gyp ('k') | src/core/SkMemory_stdlib.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkTypes.h
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index 039369119e6fd32313d56cc088712bf223ed8ccd..f2245184e66cd38e3b1169a99b807d5f2615e163 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);
« no previous file with comments | « gyp/tests.gyp ('k') | src/core/SkMemory_stdlib.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698