Commit 564379f
Fix RAM losses when creating files
File::File used to allocate RAM what was not freed when destroying the File object.
Adding a dedicated destructor war not enough to fix. It would also need copy- and move-constructors.
Removed the File::FILE(const char* name) constructor.
Changed the File::File(void) constructor to not malloc() any RAM.
Unified and changed the SDClass::open() methods.
Removed the open method without mode parameter. Instead gave the method with a mode parameter a default mode.
Now open() has the complete control over memory allocation. When it is not able to open a file no memory in left allocated.
Advantage: A created File what was not opened or was not able to be opened has not to be closed anymore to avoid memory losses. Only a scsessfilly opened file has to be closed.1 parent 9fe9579 commit 564379f
2 files changed
+30
-65
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| 122 | + | |
122 | 123 | | |
123 | 124 | | |
124 | | - | |
| 125 | + | |
125 | 126 | | |
126 | | - | |
| 127 | + | |
127 | 128 | | |
128 | | - | |
129 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
130 | 132 | | |
131 | | - | |
132 | | - | |
| 133 | + | |
133 | 134 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
143 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
144 | 148 | | |
145 | 149 | | |
146 | 150 | | |
147 | 151 | | |
148 | 152 | | |
149 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
150 | 159 | | |
151 | 160 | | |
152 | 161 | | |
| |||
167 | 176 | | |
168 | 177 | | |
169 | 178 | | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
| 179 | + | |
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
| 185 | + | |
216 | 186 | | |
217 | 187 | | |
218 | 188 | | |
| |||
617 | 587 | | |
618 | 588 | | |
619 | 589 | | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | 590 | | |
624 | 591 | | |
625 | 592 | | |
| |||
638 | 605 | | |
639 | 606 | | |
640 | 607 | | |
641 | | - | |
642 | | - | |
| 608 | + | |
| 609 | + | |
643 | 610 | | |
644 | 611 | | |
645 | 612 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
| |||
82 | 81 | | |
83 | 82 | | |
84 | 83 | | |
85 | | - | |
86 | | - | |
| 84 | + | |
87 | 85 | | |
88 | 86 | | |
89 | 87 | | |
| |||
0 commit comments