aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/c/memmem.h
Commit message (Collapse)AuthorAge
* Use our own memmem only when libc doesn’t have oneHEADmasterGravatar Benjamin Barenblat2018-11-07
Systems without memmem(3) are getting rarer every day. We can improve clarity and efficiency by relying on libc’s memmem whenever possible. Detect at compile time whether the system supports memmem(3); if it does, simply reexport its prototype through memmem.h and emit no code. If it doesn’t, actually build in the memmem code in memmem.c. Along the way, undo the renaming from commit 6dad7c645d8fdb7b7237c89ff7b34e90adbb86b1. Since we’re only creating a memmem prototype if libc doesn’t define the symbol, our prototype should never clash with libc’s. As before, authors should not assume string.h provides a prototype for memmem; they should `#include "memmem.h"` if they use the function.