Open izabera opened 8 years ago
I will take a look a this later. Do you have any suggestion on how to avoid alloca
? I cannot use malloc
because it [malloc
] can fail whilst strstr
cannot.
glibc and musl use the two way algorithm described here: http://www-igm.univ-mlv.fr/~lecroq/string/node26.html#SECTION00260 it requires O(1) space
it must not compute
strlen(haystack)
and allocating a buffer as large as (or in this case, 8 times larger than) the needle with
alloca
is an amazingly bad idea