Make sel_copyTypes_np() return the number of types in all cases.

main
theraven 16 years ago
parent a029fb2af3
commit 9c077368a8

@ -311,7 +311,11 @@ const char *sel_getType_np(SEL aSel) OBJC_NONPORTABLE;
/** /**
* Enumerates all of the type encodings associated with a given selector name * Enumerates all of the type encodings associated with a given selector name
* (up to a specified limit). * (up to a specified limit). This function returns the number of types that
* exist for a specific selector, but only copies up to count of them into the
* array passed as the types argument. This allows you to call the function
* once with a relatively small on-stack buffer and then only call it again
* with a heap-allocated buffer if there is not enough space.
*/ */
unsigned sel_copyTypes_np(const char *selName, const char **types, unsigned count) OBJC_NONPORTABLE; unsigned sel_copyTypes_np(const char *selName, const char **types, unsigned count) OBJC_NONPORTABLE;

@ -395,9 +395,13 @@ unsigned sel_copyTypes_np(const char *selName, const char **types, unsigned coun
} }
unsigned found = 0; unsigned found = 0;
while (NULL != l && found<count) while (NULL != l)
{ {
types[found++] = l->value; if (found<count)
{
types[found] = l->value;
}
found++;
l = l->next; l = l->next;
} }
return found; return found;

Loading…
Cancel
Save