OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |