Replace two xmallocs with unique_ptr