Aho corasick

please see why this code for pattern searching giving memory error for large inputs!!!
link :https://ideone.com/zevtif