fix some bugs of realloc, add frequency analyse