[map] Add hb_map_copy()

New API:
+ hb_map_copy()
This commit is contained in:
Behdad Esfahbod 2022-05-24 16:24:00 -06:00
parent 3b28cff9c0
commit efa2a5796e
4 changed files with 24 additions and 0 deletions

View File

@ -453,6 +453,7 @@ hb_icu_script_to_script
HB_MAP_VALUE_INVALID
hb_map_allocation_successful
hb_map_clear
hb_map_copy
hb_map_create
hb_map_del
hb_map_destroy

View File

@ -172,6 +172,25 @@ hb_map_allocation_successful (const hb_map_t *map)
return map->successful;
}
/**
* hb_map_copy:
* @map: A map
*
* Allocate a copy of @map.
*
* Return value: Newly-allocated map.
*
* Since: REPLACEME
**/
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);
return copy;
}
/**
* hb_map_set:

View File

@ -82,6 +82,9 @@ hb_map_get_user_data (hb_map_t *map,
HB_EXTERN hb_bool_t
hb_map_allocation_successful (const hb_map_t *map);
HB_EXTERN hb_map_t *
hb_map_copy (const hb_map_t *map);
HB_EXTERN void
hb_map_clear (hb_map_t *map);

View File

@ -186,6 +186,7 @@ hb_set_t *
hb_set_copy (const hb_set_t *set)
{
hb_set_t *copy = hb_set_create ();
if (unlikely (!copy)) return nullptr;
copy->set (*set);
return copy;
}