summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodger Combs <rodger.combs@gmail.com>2014-05-25 12:47:18 -0500
committerRodger Combs <rodger.combs@gmail.com>2014-05-25 12:47:18 -0500
commitbdf51ba70eb3858896b6b95447de7262aa4f1eee (patch)
tree8a62cb6735ed9f7356cb8790f1fe071ab750f46b
parent2c7fc01b269a31d71c4c33ac2ad0be5fc1911922 (diff)
downloadlibass-bdf51ba70eb3858896b6b95447de7262aa4f1eee.tar.bz2
libass-bdf51ba70eb3858896b6b95447de7262aa4f1eee.tar.xz
Skip useless memset() when copying a bitmap
-rw-r--r--libass/ass_bitmap.c14
1 files 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);