Module: wine Branch: master Commit: e27a633b93dd43ad17268fd6bca52ae1dc51e080 URL: http://source.winehq.org/git/wine.git/?a=commit;h=e27a633b93dd43ad17268fd6bc...
Author: Huw Davies huw@codeweavers.com Date: Tue Mar 27 11:48:40 2012 +0100
gdi32: Add a helper to create a family.
---
dlls/gdi32/freetype.c | 28 +++++++++++++++++++++------- 1 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index 1b38a8e..3afc2ea 100644 --- a/dlls/gdi32/freetype.c +++ b/dlls/gdi32/freetype.c @@ -1520,6 +1520,21 @@ static void get_family_names( FT_Face ft_face, WCHAR **name, WCHAR **english, BO } }
+/**************************************************************** + * NB This function stores the ptrs to the strings to save copying. + * Don't free them after calling. + */ +static Family *create_family( WCHAR *name, WCHAR *english_name ) +{ + Family *family = HeapAlloc( GetProcessHeap(), 0, sizeof(*family) ); + family->FamilyName = name; + family->EnglishName = english_name; + list_init( &family->faces ); + family->replacement = &family->faces; + + return family; +} + static Family *get_family( FT_Face ft_face, BOOL vertical ) { Family *family; @@ -1531,11 +1546,7 @@ static Family *get_family( FT_Face ft_face, BOOL vertical )
if (!family) { - family = HeapAlloc( GetProcessHeap(), 0, sizeof(*family) ); - family->FamilyName = strdupW( name ); - family->EnglishName = english_name ? strdupW( english_name ) : NULL; - list_init( &family->faces ); - family->replacement = &family->faces; + family = create_family( name, english_name ); list_add_tail( &font_list, &family->entry );
if (english_name) @@ -1548,8 +1559,11 @@ static Family *get_family( FT_Face ft_face, BOOL vertical ) add_font_subst( &font_subst_list, subst, 0 ); } } - HeapFree( GetProcessHeap(), 0, name ); - HeapFree( GetProcessHeap(), 0, english_name ); + else + { + HeapFree( GetProcessHeap(), 0, name ); + HeapFree( GetProcessHeap(), 0, english_name ); + }
return family; }