Skip to content

Commit

Permalink
Fixes off-by-one mistake in InArray
Browse files Browse the repository at this point in the history
  • Loading branch information
Vince0789 committed May 25, 2021
1 parent 2cfcb17 commit d9a80ff
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions array_util.inc
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ stock array_unshift(array[], value, size = sizeof array)
* <param name="size">Size of the array.</param>
* <returns>true if found, false otherwise.</returns>
*/
stock bool:InArray(needle, const haystack[], &index = 0, size = sizeof haystack)
stock bool:InArray(needle, const haystack[], &index = -1, size = sizeof haystack)
{
while(index < size)
while(++index < size)
{
if(haystack[index++] == needle)
if(haystack[index] == needle)
return true;
}
return false;
Expand Down

0 comments on commit d9a80ff

Please sign in to comment.