freemyipod r460 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r459‎ | r460 | r461 >
Date:21:14, 21 January 2011
Author:theseven
Status:new
Tags:
Comment:
emCORE: Fix some linked list handling
Modified paths:
  • /emcore/trunk/button.c (modified) (history)
  • /emcore/trunk/dir.c (modified) (history)
  • /emcore/trunk/file.c (modified) (history)

Diff [purge]

Index: emcore/trunk/button.c
@@ -100,13 +100,11 @@
101101 free(prev);
102102 }
103103 for (h = head_button_hook; h; h = h->next)
104 - {
105 - while (h && h->owner == process)
 104+ while (h->next && h->next->owner == process)
106105 {
107 - prev->next = h->next;
108 - free(h);
 106+ prev = h->next;
 107+ h->next = h->next->next;
 108+ free(prev);
109109 }
110 - prev = h;
111 - }
112110 mutex_unlock(&button_mutex);
113111 }
Index: emcore/trunk/dir.c
@@ -46,15 +46,13 @@
4747 closed++;
4848 }
4949 for (d = opendirs; d; d = d->next)
50 - {
51 - while (d && d->fatdir.file.volume == volume)
 50+ while (d->next && d->next->fatdir.file.volume == volume)
5251 {
53 - prev->next = d->next;
54 - free(d);
 52+ prev = d->next;
 53+ d->next = d->next->next;
 54+ free(prev);
5555 closed++;
5656 }
57 - prev = d;
58 - }
5957 #else
6058 (void)volume;
6159 while (opendirs)
@@ -179,15 +177,13 @@
180178 closed++;
181179 }
182180 for (d = opendirs; d; d = d->next)
183 - {
184 - while (d && d->process == process)
 181+ while (d->next && d->next->process == process)
185182 {
186 - prev->next = d->next;
187 - free(d);
 183+ prev = d->next;
 184+ d->next = d->next->next;
 185+ free(prev);
188186 closed++;
189187 }
190 - prev = d;
191 - }
192188 mutex_unlock(&dir_mutex);
193189 return closed; /* return how many we did */
194190 }
Index: emcore/trunk/file.c
@@ -236,16 +236,13 @@
237237 closed++;
238238 }
239239 for (f = openfiles; f; f = f->next)
240 - {
241 - while (f && f->process == process)
 240+ while (f->next && f->next->process == process)
242241 {
243 - prev->next = f->next;
244 - if (f->write) fsync((int)f);
245 - free(f);
 242+ prev = f->next;
 243+ f->next = f->next->next;
 244+ free(prev);
246245 closed++;
247246 }
248 - prev = f;
249 - }
250247 mutex_unlock(&file_mutex);
251248 return closed; /* return how many we did */
252249 }
@@ -771,15 +768,13 @@
772769 closed++;
773770 }
774771 for (f = openfiles; f; f = f->next)
775 - {
776 - while (f && f->fatfile.volume == volume)
 772+ while (f->next && f->next->fatfile.volume == volume)
777773 {
778 - prev->next = f->next;
779 - free(f);
 774+ prev = f->next;
 775+ f->next = f->next->next;
 776+ free(prev);
780777 closed++;
781778 }
782 - prev = f;
783 - }
784779 #else
785780 (void)volume;
786781 while (openfiles)