rename data -> buffer
use xmalloc/xrealloc/xfree
delete void function
magic
delete unuse