Fix issue #12 `Using stack allocated memory #12`

1. Use malloc for arrays instead stack frame.
2. raise NoMemoryError when malloc failed.