Nobody said:
It's not hard to write something which works, but it's easy to end up with
something which is far less efficient than it needs to be.
Do you need it now, or do you want to make sure your code is portable.
If you want it now then I think you do either have to write your own or
use GNU's if the license is compatible.
If you're "just" worried about the future, what I do is (putting the
relevant code for all such functions together in one header/source file
pair) do something like this:
use something external to C to check if the function is available
(autoconf in my case).
if it is, I conditionally #define another name, comfortably in user
namespace, for it
#define search_memory memmem
if not, #error
then a future porter "just" needs to put the prototype in the header
file where the #error is, and write the code in the C file and there he
is.
I've got "caseless_strcmp" in my code, built on strcasecmp (and, on
porting to Windows, stricmp)
Thusly:
#ifdef HAVE_STRCASECMP
#define caseless_strcmp(x,y) strcasecmp(x,y)
#else
#ifdef HAVE_STRICMP
#define caseless_strcmp(x,y) stricmp(x,y)
#else
#error Need to implement caseless string comparison here
#endif
#endif
So I push the problem off for the time being, avoid writing code I don't
need to, but don't leave anyone porting it in the future to a non GNU
system foundering with no idea of what has gone wrong.