add append_alloc function