134134_PGFT_Cache_Init (FreeTypeInstance * ft , FontCache * cache )
135135{
136136 int cache_size = MAX (ft -> cache_size - 1 , PGFT_MIN_CACHE_SIZE - 1 );
137- int i ;
138137
139138 /*
140139 * Make sure this is a power of 2.
@@ -147,18 +146,15 @@ _PGFT_Cache_Init(FreeTypeInstance *ft, FontCache *cache)
147146
148147 cache_size = cache_size + 1 ;
149148
150- cache -> nodes = _PGFT_malloc ((size_t )cache_size * sizeof (FontGlyph * ));
149+ cache -> nodes = _PGFT_calloc ((size_t )cache_size , sizeof (FontGlyph * ));
151150 if (!cache -> nodes )
152151 return -1 ;
153- for (i = 0 ; i < cache_size ; ++ i )
154- cache -> nodes [i ] = 0 ;
155- cache -> depths = _PGFT_malloc ((size_t )cache_size );
152+ cache -> depths = _PGFT_calloc ((size_t )cache_size , sizeof (FT_Byte ));
156153 if (!cache -> depths ) {
157154 _PGFT_free (cache -> nodes );
158155 cache -> nodes = 0 ;
159156 return -1 ;
160157 }
161- memset (cache -> depths , 0 , cache_size );
162158 cache -> free_nodes = 0 ;
163159 cache -> size_mask = (FT_UInt32 )(cache_size - 1 );
164160
@@ -307,13 +303,12 @@ static CacheNode *
307303allocate_node (FontCache * cache , const FontRenderMode * render , GlyphIndex_t id ,
308304 void * internal )
309305{
310- CacheNode * node = _PGFT_malloc ( sizeof (CacheNode ));
306+ CacheNode * node = _PGFT_calloc ( 1 , sizeof (CacheNode ));
311307 FT_UInt32 bucket ;
312308
313309 if (!node ) {
314310 return 0 ;
315311 }
316- memset (node , 0 , sizeof (CacheNode ));
317312
318313 if (_PGFT_LoadGlyph (& node -> glyph , id , render , internal )) {
319314 goto cleanup ;
0 commit comments