[snips]
Buy my book, Basic Algorithms.
Or not. Let's see:
int strlen(const char *str)
You follow up your example with one that uses size_t and even explains why
you should use size_t... which raises the obvious question why include
such a badly broken example at all?
This is followed up by, among other things, strcount which counts the
number of characters in a string. Problem: it returns an int, which
you've already said, on that very page, is a bad idea, yet here you go
doing it again, apparently oblivious to the notion that the string could
just as easily be longer than the range of an int *and* be filled with a
single character.
int squnch(void *data, int len, void *out)
Er... no. Once again, a complete failure to grasp the concept of size_t
and its reason for existence. One might also ask the utility of
(len & 0xFF000000) >> 24; where len is an int and the code is being
compiled on a 16-bit implementation. One might *also* ask the reasoning
behind using *signed* ints for sizes; do you expect a lot of negative
length buffers to compress?
In fact, the entire example set seems to suggest a serious fetish for
using inappropriate types and inappropriate assumptions on sizes and the
like. How the hell did you get this past a reviewer or editor?