Fixed infinite loop in enum code (thanks, Adam!)
This commit is contained in:
parent
a27c289f29
commit
e2c199b8ab
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
10302004 - Fixed a strcpy that should have been a strcat. (thanks, Tolga!)
|
10302004 - Fixed a strcpy that should have been a strcat. (thanks, Tolga!)
|
||||||
Build system respects external CFLAGS now. (thanks, Adam!)
|
Build system respects external CFLAGS now. (thanks, Adam!)
|
||||||
|
Fixed infinite loop in new enumeration code. (thanks, Adam!)
|
||||||
10062004 - Removed profiling code from physfs.c.
|
10062004 - Removed profiling code from physfs.c.
|
||||||
09292004 - Every API that can return a list of strings can now use a
|
09292004 - Every API that can return a list of strings can now use a
|
||||||
callback mechanism if the application wants to do it's own
|
callback mechanism if the application wants to do it's own
|
||||||
|
|
13
physfs.c
13
physfs.c
|
@ -1305,19 +1305,26 @@ static int locateInStringList(const char *str,
|
||||||
{
|
{
|
||||||
PHYSFS_uint32 hi = *pos - 1;
|
PHYSFS_uint32 hi = *pos - 1;
|
||||||
PHYSFS_uint32 lo = 0;
|
PHYSFS_uint32 lo = 0;
|
||||||
PHYSFS_uint32 i = hi / 2;
|
PHYSFS_uint32 i = hi >> 1;
|
||||||
int cmp;
|
int cmp;
|
||||||
|
|
||||||
|
assert(*pos != 0); /* this doesn't work with empty lists! */
|
||||||
|
|
||||||
while (hi != lo)
|
while (hi != lo)
|
||||||
{
|
{
|
||||||
cmp = strcmp(list[i], str);
|
cmp = strcmp(list[i], str);
|
||||||
if (cmp == 0) /* it's in the list already. */
|
if (cmp == 0) /* it's in the list already. */
|
||||||
return(1);
|
return(1);
|
||||||
else if (cmp < 0)
|
else if (cmp < 0)
|
||||||
|
{
|
||||||
hi = i;
|
hi = i;
|
||||||
|
i = lo + ((hi - lo) >> 1);
|
||||||
|
} /* else if */
|
||||||
else
|
else
|
||||||
lo = i;
|
{
|
||||||
i = lo + ((hi - lo) / 2);
|
lo = i + 1;
|
||||||
|
i = lo + ((1 + hi - lo) >> 1);
|
||||||
|
} /* else */
|
||||||
} /* while */
|
} /* while */
|
||||||
|
|
||||||
/* hi == lo, check it in case it's the match... */
|
/* hi == lo, check it in case it's the match... */
|
||||||
|
|
Loading…
Reference in New Issue