From cda83a0a6c9c0418e909ac0f27d735845dde85b3 Mon Sep 17 00:00:00 2001 From: Grigori Goronzy Date: Sun, 27 Jun 2010 12:25:46 +0200 Subject: [PATCH] Simple optimizations to memory handling --- libass/ass_bitmap.c | 5 ++--- libass/ass_render.c | 6 ++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/libass/ass_bitmap.c b/libass/ass_bitmap.c index c7c039d..93f2aa8 100644 --- a/libass/ass_bitmap.c +++ b/libass/ass_bitmap.c @@ -139,8 +139,8 @@ void ass_synth_done(ASS_SynthPriv *priv) static Bitmap *alloc_bitmap(int w, int h) { Bitmap *bm; - bm = calloc(1, sizeof(Bitmap)); - bm->buffer = malloc(w * h); + bm = malloc(sizeof(Bitmap)); + bm->buffer = calloc(w, h); bm->w = w; bm->h = h; bm->left = bm->top = 0; @@ -213,7 +213,6 @@ static Bitmap *glyph_to_bitmap_internal(ASS_Library *library, w = bit->width; h = bit->rows; bm = alloc_bitmap(w + 2 * bord, h + 2 * bord); - memset(bm->buffer, 0, bm->w * bm->h); bm->left = bg->left - bord; bm->top = -bg->top - bord; diff --git a/libass/ass_render.c b/libass/ass_render.c index 6596e88..4e269d4 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -198,7 +198,7 @@ static ASS_Image *my_draw_bitmap(unsigned char *bitmap, int bitmap_w, int bitmap_h, int stride, int dst_x, int dst_y, uint32_t color) { - ASS_Image *img = calloc(1, sizeof(ASS_Image)); + ASS_Image *img = malloc(sizeof(ASS_Image)); img->w = bitmap_w; img->h = bitmap_h; @@ -466,7 +466,6 @@ render_overlap(ASS_Renderer *render_priv, ASS_Image **last_tail, cur_top = top - by; // Query cache - memset(&hk, 0, sizeof(hk)); hk.a = (*last_tail)->bitmap; hk.b = (*tail)->bitmap; hk.aw = aw; @@ -1093,8 +1092,7 @@ get_outline_glyph(ASS_Renderer *render_priv, int symbol, GlyphInfo *info, memset(&v, 0, sizeof(v)); v.glyph = info->glyph; - if (info->outline_glyph) - v.outline_glyph = info->outline_glyph; + v.outline_glyph = info->outline_glyph; v.advance = info->advance; v.bbox_scaled = info->bbox; if (drawing->hash) { -- 2.40.0