Added filtering functionality, so that searching for gadgets is faster.
Added check for malloc error
Implemented comments from allanlw
Added check to short circuit the outer loop as well
Merge pull request #24 from dark-rose/dev

Made searching for gadgets faster