* include/freetype/internal/ftmemory.h [FT_DEBUG_MEMORY]: Declare FT_QAlloc_Debug and FT_QRealloc_Debug. * src/base/ftutil.c (FT_QAlloc): Fix error and debug messages. (FT_QRealloc): Call FT_QAlloc if original pointer is NULL. Fix error message.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
diff --git a/ChangeLog b/ChangeLog
index 6a7f3bb..df83950 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,25 +1,43 @@
-2004-06-23 David Turner <david@freetype.org>
-
- * include/freetype/internal/ftmemory.h, src/base/ftutil.c,
- src/base/ftmemdbg.c: introducing the new FT_QAlloc and FT_QRealloc
- functions that do perform allocation without zero-ing out the
- corresponding blocks. Corresponding macros like FT_QALLOC, FT_QNEW,
- etc.. have been defined too
-
- * include/freetype/config/ftmodule.h: changed the order of modules
- in order to _dramatically_ improve the performance of face open/close
- operations. For example, putting the TrueType driver first in the
- list results in a 5X speedup when opening Vera.ttf !!
-
- The problem is really that the PCF and/or BDF drivers are broken
- and do a lot more than necessary simply to detect that they
- cannot handle the font file.
-
- * src/sfnt/ttload.c: small optimization in the kerning table
- verifier, speeds up TrueType face opening by about 7%.
-
- Also changed code to use the new FT_QNEW_ARRAY call when
- appropriate to slightly improve performance.
+2004-06-23 Werner Lemberg <wl@gnu.org>
+
+ * include/freetype/internal/ftmemory.h [FT_DEBUG_MEMORY]: Declare
+ FT_QAlloc_Debug and FT_QRealloc_Debug.
+
+ * src/base/ftutil.c (FT_QAlloc): Fix error and debug messages.
+ (FT_QRealloc): Call FT_QAlloc if original pointer is NULL.
+ Fix error message.
+
+2004-06-23 David Turner <david@freetype.org>
+
+ * include/freetype/internal/ftmemory.h, src/base/ftutil.c
+ (FT_QAlloc, FT_QRealloc), src/base/ftdbgmem.c (FT_QAlloc_Debug,
+ FT_QRealloc_Debug): New functions that perform allocation without
+ zero-ing out the corresponding blocks.
+
+ * include/freetype/internal/ftmemory.h (FT_MEM_QALLOC,
+ FT_MEM_QREALLOC, FT_MEM_QNEW, FT_MEM_QNEW_ARRAY,
+ FT_MEM_QRENEW_ARRAY, FT_QALLOC, FT_QREALLOC, FT_QNEW, FT_QNEW_ARRAY,
+ FT_QRENEW_ARRAY): New macros.
+
+ * src/base/ftstream.c (FT_Stream_EnterFrame): Use FT_QALLOC.
+ * src/gzip/ftgzip.c (FT_Stream_OpenGzip): Use FT_QNEW_ARRAY.
+ * src/sfnt/sfobjs.c (tt_face_get_name): Use FT_QNEW_ARRAY.
+
+ * src/sfnt/ttload.c (tt_face_load_directory, tt_face_load_metrics,
+ tt_face_load_gasp): Use FT_QNEW_ARRAY.
+ (tt_face_load_kern): Use FT_QNEW_ARRAY.
+ Small optimization in the kerning table verifier; this speeds up
+ TrueType face opening by about 7%.
+ (tt_face_load_hdmx): Use FT_QNEW_ARRAY and FT_QALLOC.
+
+ * include/freetype/config/ftmodule.h: Changed the order of modules,
+ putting TrueType and Type 1 first. This dramatically improves the
+ performance of face open/close operations. For example, putting the
+ TrueType driver first in the list results in a 5x speedup when
+ opening `Vera.ttf'.
+
+ The very problem is that both the PCF and BDF drivers do a lot more
+ than necessary to detect that they cannot handle a font file.
2004-06-22 Werner Lemberg <wl@gnu.org>
diff --git a/include/freetype/internal/ftmemory.h b/include/freetype/internal/ftmemory.h
index e078ca6..ea9870f 100644
--- a/include/freetype/internal/ftmemory.h
+++ b/include/freetype/internal/ftmemory.h
@@ -65,6 +65,13 @@ FT_BEGIN_HEADER
FT_Long line_no );
FT_BASE( FT_Error )
+ FT_QAlloc_Debug( FT_Memory memory,
+ FT_Long size,
+ void* *P,
+ const char* file_name,
+ FT_Long line_no );
+
+ FT_BASE( FT_Error )
FT_Realloc_Debug( FT_Memory memory,
FT_Long current,
FT_Long size,
@@ -72,6 +79,14 @@ FT_BEGIN_HEADER
const char* file_name,
FT_Long line_no );
+ FT_BASE( FT_Error )
+ FT_QRealloc_Debug( FT_Memory memory,
+ FT_Long current,
+ FT_Long size,
+ void* *P,
+ const char* file_name,
+ FT_Long line_no );
+
FT_BASE( void )
FT_Free_Debug( FT_Memory memory,
FT_Pointer block,
@@ -108,11 +123,12 @@ FT_BEGIN_HEADER
FT_Long size,
void* *P );
-
+
FT_BASE( FT_Error )
FT_QAlloc( FT_Memory memory,
FT_Long size,
- void* *p );
+ void* *p );
+
/*************************************************************************/
/* */
@@ -148,12 +164,13 @@ FT_BEGIN_HEADER
FT_Long size,
void* *P );
-
+
FT_BASE( FT_Error )
FT_QRealloc( FT_Memory memory,
FT_Long current,
FT_Long size,
- void* *p );
+ void* *p );
+
/*************************************************************************/
/* */
@@ -217,11 +234,11 @@ FT_BEGIN_HEADER
#define FT_MEM_QALLOC( _pointer_, _size_ ) \
FT_QAlloc_Debug( memory, _size_, \
- (void**)&(_pointer_), __FILE__, __LINE__ )
+ (void**)&(_pointer_), __FILE__, __LINE__ )
#define FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) \
FT_QRealloc_Debug( memory, _current_, _size_, \
- (void**)&(_pointer_), __FILE__, __LINE__ )
+ (void**)&(_pointer_), __FILE__, __LINE__ )
#define FT_MEM_FREE( _pointer_ ) \
FT_Free_Debug( memory, (void**)&(_pointer_), __FILE__, __LINE__ )
@@ -310,7 +327,7 @@ FT_BEGIN_HEADER
#define FT_QREALLOC( _pointer_, _current_, _size_ ) \
FT_SET_ERROR( FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) )
-
+
#define FT_NEW( _pointer_ ) \
FT_SET_ERROR( FT_MEM_NEW( _pointer_ ) )
@@ -329,9 +346,7 @@ FT_BEGIN_HEADER
#define FT_QRENEW_ARRAY( _pointer_, _old_, _new_ ) \
FT_SET_ERROR( FT_MEM_QRENEW_ARRAY( _pointer_, _old_, _new_ ) )
-
-
-
+
#define FT_ALLOC_ARRAY( _pointer_, _count_, _type_ ) \
FT_SET_ERROR( FT_MEM_ALLOC( _pointer_, \
(_count_) * sizeof ( _type_ ) ) )
diff --git a/src/base/ftdbgmem.c b/src/base/ftdbgmem.c
index 5cee7dc..61227b6 100644
--- a/src/base/ftdbgmem.c
+++ b/src/base/ftdbgmem.c
@@ -696,10 +696,10 @@
FT_BASE_DEF( FT_Error )
FT_QAlloc_Debug( FT_Memory memory,
- FT_Long size,
- void* *P,
- const char* file_name,
- FT_Long line_no )
+ FT_Long size,
+ void* *P,
+ const char* file_name,
+ FT_Long line_no )
{
FT_MemTable table = (FT_MemTable)memory->user;
@@ -709,17 +709,18 @@
table->file_name = file_name;
table->line_no = line_no;
}
+
return FT_QAlloc( memory, size, P );
}
FT_BASE_DEF( FT_Error )
FT_QRealloc_Debug( FT_Memory memory,
- FT_Long current,
- FT_Long size,
- void* *P,
- const char* file_name,
- FT_Long line_no )
+ FT_Long current,
+ FT_Long size,
+ void* *P,
+ const char* file_name,
+ FT_Long line_no )
{
FT_MemTable table = (FT_MemTable)memory->user;
diff --git a/src/base/ftutil.c b/src/base/ftutil.c
index eff08ee..9d3ec43 100644
--- a/src/base/ftutil.c
+++ b/src/base/ftutil.c
@@ -4,7 +4,7 @@
/* */
/* FreeType utility file for memory and list management (body). */
/* */
-/* Copyright 2002 by */
+/* Copyright 2002, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -89,7 +89,7 @@
*P = memory->alloc( memory, size );
if ( !*P )
{
- FT_ERROR(( "FT_Alloc:" ));
+ FT_ERROR(( "FT_QAlloc:" ));
FT_ERROR(( " Out of memory? (%ld requested)\n",
size ));
@@ -99,14 +99,14 @@
else
*P = NULL;
- FT_TRACE7(( "FT_Alloc:" ));
+ FT_TRACE7(( "FT_QAlloc:" ));
FT_TRACE7(( " size = %ld, block = 0x%08p, ref = 0x%08p\n",
size, *P, P ));
return FT_Err_Ok;
}
-
+
/* documentation is in ftmemory.h */
FT_BASE_DEF( FT_Error )
@@ -160,9 +160,9 @@
FT_ASSERT( P != 0 );
- /* if the original pointer is NULL, call FT_Alloc() */
+ /* if the original pointer is NULL, call FT_QAlloc() */
if ( !*P )
- return FT_Alloc( memory, size, P );
+ return FT_QAlloc( memory, size, P );
/* if the new block if zero-sized, clear the current one */
if ( size <= 0 )
@@ -179,12 +179,13 @@
return FT_Err_Ok;
Fail:
- FT_ERROR(( "FT_Realloc:" ));
+ FT_ERROR(( "FT_QRealloc:" ));
FT_ERROR(( " Failed (current %ld, requested %ld)\n",
current, size ));
return FT_Err_Out_Of_Memory;
}
-
+
+
/* documentation is in ftmemory.h */
FT_BASE_DEF( void )
diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c
index d923b88..fa5c6a7 100644
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -1716,16 +1716,19 @@
/* ensure that the kerning pair table is sorted (yes, some */
/* fonts have unsorted tables!) */
+
#if 1
if ( num_pairs > 0 )
{
TT_Kern0_Pair pair0 = face->kern_pairs;
FT_ULong prev = TT_KERN_INDEX( pair0->left, pair0->right );
+
for ( pair0++; pair0 < limit; pair0++ )
{
FT_ULong next = TT_KERN_INDEX( pair0->left, pair0->right );
+
if ( next < prev )
goto SortIt;
@@ -1742,9 +1745,10 @@
TT_Kern0_Pair pair0 = face->kern_pairs;
FT_UInt i;
+
for ( i = 1; i < num_pairs; i++, pair0++ )
{
- if ( tt_kern_pair_compare( pair0, pair0+1 ) != -1 )
+ if ( tt_kern_pair_compare( pair0, pair0 + 1 ) != -1 )
{
ft_qsort( (void*)face->kern_pairs, (int)num_pairs,
sizeof ( TT_Kern0_PairRec ), tt_kern_pair_compare );
@@ -1753,6 +1757,7 @@
}
}
#endif
+
goto Exit;
}