Fix undefined behavior when destroying a search context.
Fix undefined behavior when destroying a search context.

Also, fix a compile error with memchr for GCC 4.4.7

Bradbev/qgrep,Bradbev/qgrep,Bradbev/qgrep,Bradbev/qgrep,Bradbev/qgrep