Hi Jakub, On Wed, Oct 09, 2024 at 09:40:11PM GMT, Jakub Łukasiewicz wrote: > On 2024-10-09 20:48 CEST, Alejandro Colomar <a...@kernel.org> wrote: > > countof() is a new term, so it doesn't yet have a meaning (except as > > given by the attribute), but it naturally fits more with number of > > elements. > > How would you call, for example, a function that returns how many times a > value is contained in a data structure (be it array, linked list, or any > other)?
list_count() or similar would be a good name. It's length that's dangerous to overload because (1) it's already used by strings, and (2) strings have the danger of the NUL terminator which is not counted by its length. But for example, it's not dangerous to misuse size for the number of elements of an array, because they're so obviously different that you'll not introduce a bug easily. I think it's okay to say wcslcpy() gets a size as the third parameter, even if pedantically it's a number of elements. So, using "count" for both arrays, and user-defined types such as linked lists, is just fine. The only _dangerous_ term is length. Have a lovely night! Alex > > ~ J.Ł. -- <https://www.alejandro-colomar.es/>
signature.asc
Description: PGP signature