Phillip Wood wrote: > On 27/05/2021 17:36, Felipe Contreras wrote: > > ZheNing Hu via GitGitGadget wrote: > > [...] > >> +static int memcasecmp(const void *vs1, const void *vs2, size_t n) > > > > Why void *? We can delcare as char *. > > If you look at how this function is used you'll see > int (*cmp_fn)(const void *, const void *, size_t); > cmp_fn = s->sort_flags & REF_SORTING_ICASE > ? memcasecmp : memcmp; Yeah, but why? We know we are comparing two char *. Presumably the reason is that memcmp and memcasecmp use void *, but that could be remedied with: cmp_fn = (int (*)(const char *, const char *, size_t))memcmp; That way the same cmp_fn could be used for the two cases. Either way I don't care particularly much. It also could be possible to use void * and do the casting in tolower(). > > (and I personally prefer lower to upper) > > We should be using tolower() as that is what POSIX specifies for > strcasecmp() [1] which we are trying to emulate and there are cases[2] where > (tolower(c1) == tolower(c2)) != (toupper(c1) == toupper(c2)) That's true. -- Felipe Contreras