From bdf51ba70eb3858896b6b95447de7262aa4f1eee Mon Sep 17 00:00:00 2001 From: Rodger Combs Date: Sun, 25 May 2014 12:47:18 -0500 Subject: Skip useless memset() when copying a bitmap --- libass/ass_bitmap.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libass/ass_bitmap.c b/libass/ass_bitmap.c index 23b24ea..f6e2022 100644 --- a/libass/ass_bitmap.c +++ b/libass/ass_bitmap.c @@ -126,7 +126,7 @@ void ass_synth_done(ASS_SynthPriv *priv) free(priv); } -Bitmap *alloc_bitmap(int w, int h) +static Bitmap *alloc_bitmap_raw(int w, int h) { Bitmap *bm; @@ -134,7 +134,6 @@ Bitmap *alloc_bitmap(int w, int h) unsigned s = ass_align(align, w); bm = malloc(sizeof(Bitmap)); bm->buffer = ass_aligned_alloc(align, s * h + 32); - memset(bm->buffer, 0, s * h + 32); bm->w = w; bm->h = h; bm->stride = s; @@ -142,6 +141,15 @@ Bitmap *alloc_bitmap(int w, int h) return bm; } +Bitmap *alloc_bitmap(int w, int h) +{ + Bitmap *bm = alloc_bitmap_raw(w, h); + if(!bm) + return NULL; + memset(bm->buffer, 0, bm->stride * bm->h + 32); + return bm; +} + void ass_free_bitmap(Bitmap *bm) { if (bm) @@ -151,7 +159,7 @@ void ass_free_bitmap(Bitmap *bm) Bitmap *copy_bitmap(const Bitmap *src) { - Bitmap *dst = alloc_bitmap(src->w, src->h); + Bitmap *dst = alloc_bitmap_raw(src->w, src->h); dst->left = src->left; dst->top = src->top; memcpy(dst->buffer, src->buffer, src->stride * src->h); -- cgit v1.2.3