Cleanup: use MEM_recallocN_id utility function

This commit is contained in:
Campbell Barton 2020-03-04 23:51:32 +11:00
parent f4463cd865
commit e7f1de5e11
1 changed files with 2 additions and 6 deletions

View File

@ -4334,18 +4334,14 @@ int rna_parameter_size(PropertyRNA *parm)
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
{
EnumPropertyItem *newitems;
int tot = *totitem;
if (tot == 0) {
*items = MEM_callocN(sizeof(EnumPropertyItem) * 8, "RNA_enum_items_add");
*items = MEM_callocN(sizeof(EnumPropertyItem) * 8, __func__);
}
else if (tot >= 8 && (tot & (tot - 1)) == 0) {
/* power of two > 8 */
newitems = MEM_callocN(sizeof(EnumPropertyItem) * tot * 2, "RNA_enum_items_add");
memcpy(newitems, *items, sizeof(EnumPropertyItem) * tot);
MEM_freeN(*items);
*items = newitems;
*items = MEM_recallocN_id(*items, sizeof(EnumPropertyItem) * tot * 2, __func__);
}
(*items)[tot] = *item;