ptvcursor: just do a realloc.

ptvcursor_new_subtree_levels() just needs to do a wmem_realloc() on the
subtree array; that will take care of ensuring the old data is in the
new array.
This commit is contained in:
Guy Harris 2021-04-16 00:38:13 -07:00 committed by Wireshark GitLab Utility
parent 80cfcd8227
commit 512adcb046
1 changed files with 1 additions and 4 deletions

View File

@ -1113,15 +1113,12 @@ static void
ptvcursor_new_subtree_levels(ptvcursor_t *ptvc)
{
subtree_lvl *pushed_tree;
size_t pushed_tree_len = sizeof(subtree_lvl) * ptvc->pushed_tree_max;
DISSECTOR_ASSERT(ptvc->pushed_tree_max <= SUBTREE_MAX_LEVELS-SUBTREE_ONCE_ALLOCATION_NUMBER);
ptvc->pushed_tree_max += SUBTREE_ONCE_ALLOCATION_NUMBER;
pushed_tree = (subtree_lvl *)wmem_alloc(wmem_packet_scope(), sizeof(subtree_lvl) * ptvc->pushed_tree_max);
pushed_tree = (subtree_lvl *)wmem_realloc(wmem_packet_scope(), (void *)ptvc->pushed_tree, sizeof(subtree_lvl) * ptvc->pushed_tree_max);
DISSECTOR_ASSERT(pushed_tree != NULL);
if (ptvc->pushed_tree)
memcpy(pushed_tree, ptvc->pushed_tree, pushed_tree_len);
ptvc->pushed_tree = pushed_tree;
}