fix compile error on ubuntu 12.04

Add memory.h and stdlib.h for memcpy/free/malloc.