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

Side by Side Diff: src/utils/SkRTConf.cpp

Issue 136963004: fix leaks in SkConf (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 10 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
« no previous file with comments | « include/utils/SkRTConf.h ('k') | no next file » | 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 2013 Google Inc. 2 * Copyright 2013 Google Inc.
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 #include "SkRTConf.h" 8 #include "SkRTConf.h"
9 #include "SkOSFile.h" 9 #include "SkOSFile.h"
10 10
(...skipping 26 matching lines...) Expand all
37 char *keyptr = strtok(line, sep); 37 char *keyptr = strtok(line, sep);
38 if (!keyptr) { 38 if (!keyptr) {
39 continue; 39 continue;
40 } 40 }
41 41
42 char *valptr = strtok(NULL, sep); 42 char *valptr = strtok(NULL, sep);
43 if (!valptr) { 43 if (!valptr) {
44 continue; 44 continue;
45 } 45 }
46 46
47 SkString* key = new SkString(keyptr); 47 SkString* key = SkNEW_ARGS(SkString,(keyptr));
48 SkString* val = new SkString(valptr); 48 SkString* val = SkNEW_ARGS(SkString,(valptr));
49 49
50 fConfigFileKeys.append(1, &key); 50 fConfigFileKeys.append(1, &key);
51 fConfigFileValues.append(1, &val); 51 fConfigFileValues.append(1, &val);
52 } 52 }
53 sk_fclose(fp); 53 sk_fclose(fp);
54 } 54 }
55 55
56 SkRTConfRegistry::~SkRTConfRegistry() {
57 ConfMap::Iter iter(fConfs);
58 SkTDArray<SkRTConfBase *> *confArray;
59
60 while (iter.next(&confArray)) {
61 delete confArray;
62 }
63
64 for (int i = 0 ; i < fConfigFileKeys.count() ; i++) {
65 SkDELETE(fConfigFileKeys[i]);
66 SkDELETE(fConfigFileValues[i]);
67 }
68 }
69
56 const char *SkRTConfRegistry::configFileLocation() const { 70 const char *SkRTConfRegistry::configFileLocation() const {
57 return "skia.conf"; // for now -- should probably do something fancier like home directories or whatever. 71 return "skia.conf"; // for now -- should probably do something fancier like home directories or whatever.
58 } 72 }
59 73
60 // dump all known runtime config options to the file with their default values. 74 // dump all known runtime config options to the file with their default values.
61 // to trigger this, make a config file of zero size. 75 // to trigger this, make a config file of zero size.
62 void SkRTConfRegistry::possiblyDumpFile() const { 76 void SkRTConfRegistry::possiblyDumpFile() const {
63 const char *path = configFileLocation(); 77 const char *path = configFileLocation();
64 SkFILE *fp = sk_fopen(path, kRead_SkFILE_Flag); 78 SkFILE *fp = sk_fopen(path, kRead_SkFILE_Flag);
65 if (!fp) { 79 if (!fp) {
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 sk_setenv("skia_nonexistent_item", "132"); 341 sk_setenv("skia_nonexistent_item", "132");
328 int result = 0; 342 int result = 0;
329 registryWithoutContents.parse("nonexistent.item", &result); 343 registryWithoutContents.parse("nonexistent.item", &result);
330 SkASSERT(result == 132); 344 SkASSERT(result == 132);
331 } 345 }
332 346
333 SkRTConfRegistry::SkRTConfRegistry(bool) 347 SkRTConfRegistry::SkRTConfRegistry(bool)
334 : fConfs(100) { 348 : fConfs(100) {
335 } 349 }
336 #endif 350 #endif
OLDNEW
« no previous file with comments | « include/utils/SkRTConf.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698