Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: src/ports/SkFontConfigParser_android.h

Issue 226183002: Prevent potential leaking of memory by using SkString and SkTArray. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ports/SkFontConfigInterface_android.cpp ('k') | src/ports/SkFontConfigParser_android.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The Android Open Source Project 2 * Copyright 2011 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SKFONTCONFIGPARSER_ANDROID_H_ 8 #ifndef SKFONTCONFIGPARSER_ANDROID_H_
9 #define SKFONTCONFIGPARSER_ANDROID_H_ 9 #define SKFONTCONFIGPARSER_ANDROID_H_
10 10
11 #include "SkTypes.h" 11 #include "SkTypes.h"
12 12
13 #include "SkPaintOptionsAndroid.h" 13 #include "SkPaintOptionsAndroid.h"
14 #include "SkString.h" 14 #include "SkString.h"
15 #include "SkTDArray.h" 15 #include "SkTDArray.h"
16 16
17 struct FontFileInfo { 17 struct FontFileInfo {
18 FontFileInfo() : fFileName(NULL) {} 18 SkString fFileName;
19
20 const char* fFileName;
21 SkPaintOptionsAndroid fPaintOptions; 19 SkPaintOptionsAndroid fPaintOptions;
22 }; 20 };
23 21
24 /** 22 /**
25 * The FontFamily data structure is created during parsing and handed back to 23 * The FontFamily data structure is created during parsing and handed back to
26 * Skia to fold into its representation of font families. fNames is the list of 24 * Skia to fold into its representation of font families. fNames is the list of
27 * font names that alias to a font family. fontFileArray is the list of informat ion 25 * font names that alias to a font family. fontFileArray is the list of informat ion
28 * about each file. Order is the priority order for the font. This is 26 * about each file. Order is the priority order for the font. This is
29 * used internally to determine the order in which to place fallback fonts as 27 * used internally to determine the order in which to place fallback fonts as
30 * they are read from the configuration files. 28 * they are read from the configuration files.
31 */ 29 */
32 struct FontFamily { 30 struct FontFamily {
33 FontFamily() : fIsFallbackFont(false), order(-1) {} 31 FontFamily() : fIsFallbackFont(false), order(-1) {}
34 32
35 SkTDArray<const char*> fNames; 33 SkTArray<SkString> fNames;
36 SkTDArray<FontFileInfo*> fFontFiles; 34 SkTArray<FontFileInfo> fFontFiles;
37 bool fIsFallbackFont; 35 bool fIsFallbackFont;
38 int order; // only used internally by SkFontConfigParser 36 int order; // only used internally by SkFontConfigParser
39 }; 37 };
40 38
41 namespace SkFontConfigParser { 39 namespace SkFontConfigParser {
42 40
43 /** 41 /**
44 * Parses all system font configuration files and returns the results in an 42 * Parses all system font configuration files and returns the results in an
45 * array of FontFamily structures. 43 * array of FontFamily structures.
46 */ 44 */
47 void GetFontFamilies(SkTDArray<FontFamily*> &fontFamilies); 45 void GetFontFamilies(SkTDArray<FontFamily*> &fontFamilies);
48 46
49 /** 47 /**
50 * Parses all test font configuration files and returns the results in an 48 * Parses all test font configuration files and returns the results in an
51 * array of FontFamily structures. 49 * array of FontFamily structures.
52 */ 50 */
53 void GetTestFontFamilies(SkTDArray<FontFamily*> &fontFamilies, 51 void GetTestFontFamilies(SkTDArray<FontFamily*> &fontFamilies,
54 const char* testMainConfigFile, 52 const char* testMainConfigFile,
55 const char* testFallbackConfigFile); 53 const char* testFallbackConfigFile);
56 54
57 SkString GetLocale(); 55 SkString GetLocale();
58 56
59 } // SkFontConfigParser namespace 57 } // SkFontConfigParser namespace
60 58
61 #endif /* SKFONTCONFIGPARSER_ANDROID_H_ */ 59 #endif /* SKFONTCONFIGPARSER_ANDROID_H_ */
OLDNEW
« no previous file with comments | « src/ports/SkFontConfigInterface_android.cpp ('k') | src/ports/SkFontConfigParser_android.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698