From 5042a0a8ef8bb4a3247b924bd1f34710d0a9fa0f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 Jan 2013 14:04:01 +0000 Subject: use guarded malloc for blf texture --- source/blender/blenfont/intern/blf_glyph.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 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 9c7623f3757..12c0088e93e 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -83,7 +83,7 @@ GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font) memset(gc->glyph_ascii_table, 0, sizeof(gc->glyph_ascii_table)); memset(gc->bucket, 0, sizeof(gc->bucket)); - gc->textures = (GLuint *)malloc(sizeof(GLuint) * 256); + gc->textures = (GLuint *)MEM_mallocN(sizeof(GLuint) * 256, __func__); gc->ntex = 256; gc->cur_tex = -1; gc->x_offs = 0; @@ -150,7 +150,7 @@ void blf_glyph_cache_free(GlyphCacheBLF *gc) if (gc->cur_tex + 1 > 0) glDeleteTextures(gc->cur_tex + 1, gc->textures); - free((void *)gc->textures); + MEM_freeN((void *)gc->textures); MEM_freeN(gc); } @@ -178,8 +178,7 @@ static void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc) gc->p2_height = font->max_tex_size; tot_mem = gc->p2_width * gc->p2_height; - buf = (unsigned char *)malloc(tot_mem); - memset((void *)buf, 0, tot_mem); + buf = (unsigned char *)MEM_callocN(tot_mem, __func__); glGenTextures(1, &gc->textures[gc->cur_tex]); glBindTexture(GL_TEXTURE_2D, (font->tex_bind_state = gc->textures[gc->cur_tex])); @@ -189,7 +188,7 @@ static void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc) 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); - free((void *)buf); + MEM_freeN((void *)buf); } GlyphBLF *blf_glyph_search(GlyphCacheBLF *gc, unsigned int c) -- cgit v1.2.3