• R/O
  • SSH
  • HTTPS

gtaconfig: 提交


Commit MetaInfo

修訂45 (tree)
時間2021-09-24 17:55:46
作者quiret

Log Message

- various fixes

Change Summary

差異

--- include/gtaconfig/ini.h (revision 44)
+++ include/gtaconfig/ini.h (revision 45)
@@ -3,7 +3,7 @@
33
44 #include "syntax.h"
55
6-#include <string.h>
6+#include <sdk/Vector.h>
77
88 class CINI
99 {
@@ -37,22 +37,19 @@
3737
3838 ~Entry()
3939 {
40- settingList_t::iterator iter;
41-
42- for (iter = settings.begin(); iter != settings.end(); iter++)
43- delete *iter;
44-
40+ for ( Setting *set : this->settings )
41+ {
42+ delete set;
43+ }
4544 free(m_name);
4645 }
4746
4847 Setting* Find(const char *key)
4948 {
50- settingList_t::iterator iter;
51-
52- for (iter = settings.begin(); iter != settings.end(); iter++)
49+ for ( Setting *set : this->settings )
5350 {
54- if (strcmp((*iter)->key, key) == 0)
55- return *iter;
51+ if (strcmp(set->key, key) == 0)
52+ return set;
5653 }
5754
5855 return nullptr;
@@ -75,7 +72,7 @@
7572 set->key = _strdup(key);
7673 set->value = _strdup(value);
7774
78- settings.push_back( set );
75+ settings.AddToBack( set );
7976 }
8077
8178 inline const char* Get(const char *key)
@@ -130,7 +127,7 @@
130127 char* m_name;
131128
132129 private:
133- typedef std::list <Setting*> settingList_t;
130+ typedef eir::Vector <Setting*, CRTHeapAllocator> settingList_t;
134131
135132 settingList_t settings;
136133 };
@@ -155,7 +152,7 @@
155152 }
156153
157154 private:
158- typedef std::list <Entry*> entryList_t;
155+ typedef eir::Vector <Entry*, CRTHeapAllocator> entryList_t;
159156
160157 entryList_t entries;
161158 };
--- src/StdInc.h (revision 44)
+++ src/StdInc.h (revision 45)
@@ -9,7 +9,7 @@
99 // Default allocator for this library.
1010 struct ConfigHeapAllocator
1111 {
12- AINLINE static void* Allocate( void *refPtr, size_t memSize, size_t alignment )
12+ AINLINE static void* Allocate( void *refPtr, size_t memSize, size_t alignment ) noexcept
1313 {
1414 #ifdef _MSC_VER
1515 return _aligned_malloc( memSize, alignment );
@@ -18,13 +18,8 @@
1818 #endif
1919 }
2020
21- AINLINE static bool Resize( void *refPtr, void *memPtr, size_t memSize )
21+ AINLINE static void Free( void *refPtr, void *memPtr ) noexcept
2222 {
23- return false;
24- }
25-
26- AINLINE static void Free( void *refPtr, void *memPtr )
27- {
2823 #ifdef _MSC_VER
2924 _aligned_free( memPtr );
3025 #else
--- src/ini.cpp (revision 44)
+++ src/ini.cpp (revision 45)
@@ -54,7 +54,7 @@
5454
5555 section = new Entry( name );
5656
57- entries.push_back( section );
57+ entries.AddToBack( section );
5858
5959 hasProcessedSpecialToken = true;
6060 }
@@ -104,23 +104,21 @@
104104
105105 CINI::~CINI()
106106 {
107- entryList_t::iterator iter;
108-
109- for (iter = entries.begin(); iter != entries.end(); iter++)
110- delete *iter;
107+ for ( Entry *ent : this->entries )
108+ {
109+ delete ent;
110+ }
111111 }
112112
113113 CINI::Entry* CINI::GetEntry(const char *entry)
114114 {
115- entryList_t::iterator iter;
116-
117- for (iter = entries.begin(); iter != entries.end(); iter++)
115+ for ( Entry *ent : this->entries )
118116 {
119- if (strcmp((*iter)->m_name, entry) == 0)
120- return *iter;
117+ if (strcmp(ent->m_name, entry) == 0)
118+ return ent;
121119 }
122120
123- return NULL;
121+ return nullptr;
124122 }
125123
126124 const char* CINI::Get(const char *entry, const char *key)
@@ -128,7 +126,7 @@
128126 Entry *section = GetEntry(entry);
129127
130128 if (!section)
131- return NULL;
129+ return nullptr;
132130
133131 return section->Get( key );
134132 }
Show on old repository browser