diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-01-08 18:04:01 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-01-08 18:04:01 +0400 |
commit | 5042a0a8ef8bb4a3247b924bd1f34710d0a9fa0f (patch) | |
tree | 3535f5810ed2028e5e1af2283f024a631a0fba43 /source/blender | |
parent | 4ed46b4043e5a84cf02a0a18ba1f8acb462e2762 (diff) |
use guarded malloc for blf texture
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenfont/intern/blf_glyph.c | 9 |
1 files changed, 4 insertions, 5 deletions
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) |