Using memcpy and memset on link_stack function.
Using memcpy to handle the avail pointer.