add a pair of shorthand macros to validate an index into an array
Two variations:
IndexOk(idx, array) validate that idx is a valid index into the array
IndexOkT(idx, array) validate that idx is a valid index into the
array, excluding the final Terminator element
This commit is contained in:
@@ -112,7 +112,7 @@ static const struct propname {
|
||||
const char *
|
||||
property_by_index(int idx, int *propertynum)
|
||||
{
|
||||
if (!(idx >= 0 && idx < SIZE(propertynames) - 1))
|
||||
if (!IndexOkT(idx, propertynames))
|
||||
idx = SIZE(propertynames) - 1;
|
||||
|
||||
if (propertynum)
|
||||
|
||||
Reference in New Issue
Block a user