summaryrefslogtreecommitdiff
path: root/src/fontcache.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-01-10 18:56:51 +0000
committerrubidium <rubidium@openttd.org>2007-01-10 18:56:51 +0000
commita7d0cdf95fd8847ab76b35446e1c9b77f8ef1cb7 (patch)
tree1a1c59c13ddb1d152052f3a3a0bcffe4fb531173 /src/fontcache.cpp
parentce75f6549dd379b506c9f1e9383bd881aa7cf5c7 (diff)
downloadopenttd-a7d0cdf95fd8847ab76b35446e1c9b77f8ef1cb7.tar.xz
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
Diffstat (limited to 'src/fontcache.cpp')
-rw-r--r--src/fontcache.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/fontcache.cpp b/src/fontcache.cpp
index d555eea94..e60fe8bc7 100644
--- a/src/fontcache.cpp
+++ b/src/fontcache.cpp
@@ -11,6 +11,7 @@
#include "gfx.h"
#include "string.h"
#include "fontcache.h"
+#include "helpers.hpp"
#ifdef WITH_FREETYPE
@@ -77,7 +78,7 @@ static FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
* normal char to match the data returned by RegEnumValue,
* otherwise just use parameter */
#if defined(UNICODE)
- font_namep = malloc(MAX_PATH * sizeof(TCHAR));
+ MallocT(&font_namep, MAX_PATH);
MB_TO_WIDE_BUFFER(font_name, font_namep, MAX_PATH * sizeof(TCHAR));
#else
font_namep = (char*)font_name; // only cast because in unicode pointer is not const
@@ -345,12 +346,12 @@ static void SetGlyphPtr(FontSize size, WChar key, const GlyphEntry *glyph)
{
if (_glyph_ptr[size] == NULL) {
DEBUG(freetype, 3, "Allocating root glyph cache for size %u", size);
- _glyph_ptr[size] = calloc(256, sizeof(**_glyph_ptr));
+ CallocT(&_glyph_ptr[size], 256);
}
if (_glyph_ptr[size][GB(key, 8, 8)] == NULL) {
DEBUG(freetype, 3, "Allocating glyph cache for range 0x%02X00, size %u", GB(key, 8, 8), size);
- _glyph_ptr[size][GB(key, 8, 8)] = calloc(256, sizeof(***_glyph_ptr));
+ CallocT(&_glyph_ptr[size][GB(key, 8, 8)], 256);
}
DEBUG(freetype, 4, "Set glyph for unicode character 0x%04X, size %u", key, size);
@@ -395,7 +396,7 @@ const Sprite *GetGlyph(FontSize size, WChar key)
height = max(1, slot->bitmap.rows + (size == FS_NORMAL));
/* FreeType has rendered the glyph, now we allocate a sprite and copy the image into it */
- sprite = calloc(width * height + 8, 1);
+ sprite = (Sprite*)calloc(width * height + 8, 1);
sprite->info = 1;
sprite->width = width;
sprite->height = height;
@@ -483,8 +484,8 @@ SpriteID GetUnicodeGlyph(FontSize size, uint32 key)
void SetUnicodeGlyph(FontSize size, uint32 key, SpriteID sprite)
{
- if (_unicode_glyph_map[size] == NULL) _unicode_glyph_map[size] = calloc(256, sizeof(*_unicode_glyph_map[size]));
- if (_unicode_glyph_map[size][GB(key, 8, 8)] == NULL) _unicode_glyph_map[size][GB(key, 8, 8)] = calloc(256, sizeof(**_unicode_glyph_map[size]));
+ if (_unicode_glyph_map[size] == NULL) CallocT(&_unicode_glyph_map[size], 256);
+ if (_unicode_glyph_map[size][GB(key, 8, 8)] == NULL) CallocT(&_unicode_glyph_map[size][GB(key, 8, 8)], 256);
_unicode_glyph_map[size][GB(key, 8, 8)][GB(key, 0, 8)] = sprite;
}