[map] Adjust hb_map_copy()

This commit is contained in:
Behdad Esfahbod 2023-01-16 12:07:15 -07:00
parent e0883d60e4
commit b7f1c30c20
1 changed files with 5 additions and 4 deletions

View File

@ -174,7 +174,7 @@ hb_map_allocation_successful (const hb_map_t *map)
* *
* Allocate a copy of @map. * Allocate a copy of @map.
* *
* Return value: Newly-allocated map. * Return value: (transfer full): Newly-allocated map.
* *
* Since: 4.4.0 * Since: 4.4.0
**/ **/
@ -182,9 +182,10 @@ hb_map_t *
hb_map_copy (const hb_map_t *map) hb_map_copy (const hb_map_t *map)
{ {
hb_map_t *copy = hb_map_create (); hb_map_t *copy = hb_map_create ();
if (unlikely (!copy)) return nullptr; if (unlikely (copy->in_error ()))
copy->resize (map->population); return hb_map_get_empty ();
hb_copy (*map, *copy);
*copy = *map;
return copy; return copy;
} }