Using hashtable instead of array stores the terminals. Rewrite the malloc func, eg: mNewXXX => newXXX.