s4-auth: Rework memory handling to use a tmp_ctx