memcpy and mktemp, just like gnu