/* Add a group address to the array of group addresses. The caller should make sure that no duplicated address existed in the array. */
EFI_STATUS Ip6CombineGroups(IN OUT IP6_PROTOCOL *IpInstance, IN EFI_IPv6_ADDRESS *Group)
/* Add a group address to the array of group addresses. The caller should make sure that no duplicated address existed in the array. */
EFI_STATUS Ip6CombineGroups(IN OUT IP6_PROTOCOL *IpInstance, IN EFI_IPv6_ADDRESS *Group)
{
  EFI_IPv6_ADDRESS  *GroupList;
  NET_CHECK_SIGNATURE (IpInstance, IP6_PROTOCOL_SIGNATURE);
  ASSERT (Group != NULL && IP6_IS_MULTICAST (Group));
  IpInstance->GroupCount++;
  GroupList = AllocatePool (IpInstance->GroupCount * sizeof (EFI_IPv6_ADDRESS));
  if (GroupList == NULL) {
    return EFI_OUT_OF_RESOURCES;
  }
  if (IpInstance->GroupCount > 1) {
    ASSERT (IpInstance->GroupList != NULL);
    CopyMem (
      GroupList,
      IpInstance->GroupList,
      (IpInstance->GroupCount - 1) * sizeof (EFI_IPv6_ADDRESS)
      );
    FreePool (IpInstance->GroupList);
  }
  IP6_COPY_ADDRESS (GroupList + (IpInstance->GroupCount - 1), Group);
  IpInstance->GroupList = GroupList;
  return EFI_SUCCESS;
}