* first bunch of updates toward new release
[navit-package] / debian / patches / memfixes.patch
1 Index: navit/navit/font/freetype/font_freetype.c
2 ===================================================================
3 --- navit.orig/navit/font/freetype/font_freetype.c      2010-01-28 22:50:40.680020207 +0100
4 +++ navit/navit/font/freetype/font_freetype.c   2010-01-28 22:51:12.632935443 +0100
5 @@ -5,8 +5,8 @@
6  #include <ft2build.h>
7  #include <glib.h>
8  #include FT_FREETYPE_H
9 -#ifdef USE_CACHING
10 -#undef USE_CACHING
11 +#ifndef USE_CACHING
12 +#define USE_CACHING 1
13  #endif
14  #if USE_CACHING
15  #include FT_CACHE_H
16 @@ -132,11 +132,10 @@
17                         if (glyph_bbox.yMax > bbox.yMax)
18                                 bbox.yMax = glyph_bbox.yMax;
19                         p = g_utf8_next_char(p);
20 -#if USE_CACHING
21 +
22                         FT_Done_Glyph(glyph);
23 +#if USE_CACHING
24                         FTC_Node_Unref(anode, manager);
25 -#else
26 -                       FT_Done_Glyph(glyph);
27  #endif
28                 }
29                 if (bbox.xMin > bbox.xMax) {
30 @@ -239,8 +238,9 @@
31  
32                 curr->dx = glyph->advance.x >> 10;
33                 curr->dy = -glyph->advance.y >> 10;
34 -#if USE_CACHING
35 +
36                 FT_Done_Glyph(glyph);
37 +#if USE_CACHING
38                 FTC_Node_Unref(anode, manager);
39  #endif
40                 p = g_utf8_next_char(p);
41 @@ -265,6 +265,9 @@
42  static void
43  font_destroy(struct graphics_font_priv *font)
44  {
45 +#ifndef USE_CACHING
46 +       FT_Done_Face(((struct font_freetype_font*) font)->face);
47 +#endif
48         g_free(font);
49         /* TODO: free font->face */
50  }
51 @@ -292,25 +295,34 @@
52  {
53         FT_Error ret;
54         char *fontfile,*fontindex;
55 +
56         if (! face_id)
57                 return FT_Err_Invalid_Handle;
58 +
59         fontfile=g_strdup((char *)face_id);
60         dbg(1,"fontfile=%s\n", fontfile);
61         fontindex=strrchr(fontfile,'/');
62 +
63         if (! fontindex) {
64 +               dbg(0,"Error while getting the fontindex");
65                 g_free(fontfile);
66                 return FT_Err_Invalid_Handle;
67         }
68 +
69         *fontindex++='\0';
70         dbg(1,"new face %s %d\n", fontfile, atoi(fontindex));
71         ret = FT_New_Face( library, fontfile, atoi(fontindex), aface );
72         if(ret) {
73 -              dbg(0,"Error while creating freetype face: %d\n", ret);
74 -              return ret;
75 +                       dbg(0,"Error while creating freetype face: %d\n", ret);
76 +                       g_free(fontfile);
77 +                       return ret;
78         }
79 +
80         if((ret = FT_Select_Charmap(*aface, FT_ENCODING_UNICODE))) {
81 -              dbg(0,"Error while creating freetype face: %d\n", ret);
82 +                       dbg(0,"Error while creating freetype face: %d\n", ret);
83         }
84 +
85 +       g_free(fontfile);
86         return 0;
87  }
88  #endif