diff options
author | Rodger Combs <rodger.combs@gmail.com> | 2016-06-23 23:39:06 -0500 |
---|---|---|
committer | Grigori Goronzy <greg@chown.ath.cx> | 2016-09-24 20:48:19 +0200 |
commit | 25486d7b3dfe7226553a2af74e15db4005a6a201 (patch) | |
tree | f7c22990f539c7b1cea4424b4132b3282dcc10c2 /libass/ass_utils.c | |
parent | 8465a0c6c38301246695ad8e83baee57847f33db (diff) | |
download | libass-25486d7b3dfe7226553a2af74e15db4005a6a201.tar.bz2 libass-25486d7b3dfe7226553a2af74e15db4005a6a201.tar.xz |
bitmap: use calloc instead of malloc/memset
This can improve perf somewhat with large bitmaps
Diffstat (limited to 'libass/ass_utils.c')
-rw-r--r-- | libass/ass_utils.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libass/ass_utils.c b/libass/ass_utils.c index bcaeec1..9dc2358 100644 --- a/libass/ass_utils.c +++ b/libass/ass_utils.c @@ -79,12 +79,13 @@ char *ass_strndup(const char *s, size_t n) } #endif -void *ass_aligned_alloc(size_t alignment, size_t size) +void *ass_aligned_alloc(size_t alignment, size_t size, bool zero) { assert(!(alignment & (alignment - 1))); // alignment must be power of 2 if (size >= SIZE_MAX - alignment - sizeof(void *)) return NULL; - char *allocation = malloc(size + sizeof(void *) + alignment - 1); + char *allocation = zero ? calloc(size + sizeof(void *) + alignment - 1, 1) + : malloc(size + sizeof(void *) + alignment - 1); if (!allocation) return NULL; char *ptr = allocation + sizeof(void *); |