add build dir

add build dir and update some "malloc" to "(type)malloc".