Fix undefined behavior when destroying a search context.

Also, fix a compile error with memchr for GCC 4.4.7
Merge pull request #3 from omghaxzs/master

Fix undefined behavior when destroying a search context.