Don't abuse the const pointer we've been passed in, allocate memory instead.
XXX: This is expensive.