Rewite the code by using C99 initialization and remove some useless code
Rearrange the code
Watch: replace "0" to "NULL"