From b7f1c30c2062837932d70bd7fbd5fb69289e4f36 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 16 Jan 2023 12:07:15 -0700 Subject: [PATCH] [map] Adjust hb_map_copy() --- src/hb-map.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/hb-map.cc b/src/hb-map.cc index 8c027b895..b9dfa003f 100644 --- a/src/hb-map.cc +++ b/src/hb-map.cc @@ -174,7 +174,7 @@ hb_map_allocation_successful (const hb_map_t *map) * * Allocate a copy of @map. * - * Return value: Newly-allocated map. + * Return value: (transfer full): Newly-allocated map. * * Since: 4.4.0 **/ @@ -182,9 +182,10 @@ hb_map_t * hb_map_copy (const hb_map_t *map) { hb_map_t *copy = hb_map_create (); - if (unlikely (!copy)) return nullptr; - copy->resize (map->population); - hb_copy (*map, *copy); + if (unlikely (copy->in_error ())) + return hb_map_get_empty (); + + *copy = *map; return copy; }