From 7c6d52eb07c4bd8142a95eca1dbdc794063859b8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 17 Jan 2014 02:16:22 +1100 Subject: BLF: avoid allocating empty array in blf_glyph_cache_texture --- source/blender/blenfont/intern/blf_glyph.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'source/blender/blenfont') diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 8a734f95db2..637f534563f 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -154,8 +154,7 @@ void blf_glyph_cache_free(GlyphCacheBLF *gc) static void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc) { - int tot_mem, i; - unsigned char *buf; + int i; /* move the index. */ gc->cur_tex++; @@ -175,9 +174,6 @@ static void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc) if (gc->p2_height > font->max_tex_size) gc->p2_height = font->max_tex_size; - tot_mem = gc->p2_width * gc->p2_height; - buf = (unsigned char *)MEM_callocN((size_t)tot_mem, __func__); - glGenTextures(1, &gc->textures[gc->cur_tex]); glBindTexture(GL_TEXTURE_2D, (font->tex_bind_state = gc->textures[gc->cur_tex])); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); @@ -185,8 +181,7 @@ static void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, gc->p2_width, gc->p2_height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, buf); - MEM_freeN((void *)buf); + glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, gc->p2_width, gc->p2_height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, NULL); } GlyphBLF *blf_glyph_search(GlyphCacheBLF *gc, unsigned int c) -- cgit v1.2.3