Chameleon

Chameleon Commit Details

Date:2010-07-25 21:32:08 (13 years 8 months ago)
Author:Evan Lojewski
Commit:246
Parents: 245
Message:Binary search fix
Changes:
M/branches/zef/artwork/themes/default/device_ext3.png
M/branches/zef/artwork/themes/default/device_cdrom.png
M/branches/zef/artwork/themes/default/device_hfsplus.png
M/branches/zef/artwork/themes/default/device_selection.png
M/branches/zef/artwork/themes/default/device_ntfs.png
M/branches/zef/artwork/themes/default/device_generic.png
M/branches/zef/artwork/themes/default/device_fat32.png
M/branches/zef/i386/boot2/gui.c
M/branches/zef/artwork/themes/default/device_fat16.png

File differences

branches/zef/i386/boot2/gui.c
176176
177177
178178
179
180
179
180
181
182
183
184
185
186
187
181188
182
183
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
184213
185
214
186215
187216
188217
......
251280
252281
253282
254
283
255284
256285
257286
#ifdef EMBED_THEME
static int getEmbeddedImageIndexByName(const char *name)
{
int i;
for (i = 0; i < sizeof(embeddedImages) / sizeof(embeddedImages[0]); i++)
int upperLimit = sizeof(embeddedImages) / sizeof(embeddedImages[0]) - 1;
int lowerLimit = 0;
int compareIndex = (upperLimit - lowerLimit) >> 1; // Midpoint
int result;
// NOTE: This algorithm assumes that the embeddedImages is sorted.
// This is currently done using the make file. If the array is every
// manualy generated, this *will* fail to work properly.
while((result = strcmp(name, embeddedImages[compareIndex].name)) != 0)
{
if (strcmp(name, embeddedImages[i].name) == 0)
return i; // found the name
if(result > 0)// We need to search a HIGHER index
{
if(compareIndex != lowerLimit)
{
lowerLimit = compareIndex;
}
else
{
return -1;
}
compareIndex = (upperLimit + lowerLimit + 1) >> 1;// Midpoint, round up
}
else //if(result < 0) // We Need to search a LOWER index
{
if(compareIndex != upperLimit)
{
upperLimit = compareIndex;
}
else
{
return -1;
}
compareIndex = (upperLimit + lowerLimit) >> 1;// Midpoint, round down
}
}
return -1;
return compareIndex;
}
#endif
{
#ifndef EMBED_THEME
printf("ERROR: GUI: could not open '%s/%s.png'!\n", theme_name, image);
sleep(2);
sleep(2);
#endif
return 1;
}

Archive Download the corresponding diff file

Revision: 246