Skip to content

Commit

Permalink
x_list.c cleanup and compile fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
agraef committed Sep 30, 2024
1 parent bc664d0 commit 4e520c2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pd/src/x_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,9 +568,9 @@ static void list_store_list(t_list_store *x, t_symbol *s,
}

/* function to restore gpointers after the list has moved in memory */
static void list_store_restore_gpointers(t_list_store *x, int offset, int count)
static void alist_restore_gpointers(t_alist *x, int offset, int count)
{
t_listelem *vec = x->x_alist.l_vec + offset;
t_listelem *vec = x->l_vec + offset;
while (count--)
{
if (vec->l_a.a_type == A_POINTER)
Expand All @@ -594,15 +594,15 @@ static void list_store_doinsert(t_list_store *x, t_symbol *s,
}
/* fix gpointers in case resizebytes() has moved the alist in memory */
if (x->x_alist.l_vec != oldptr && x->x_alist.l_npointer)
list_store_restore_gpointers(&x->x_alist, 0, x->x_alist.l_n);
alist_restore_gpointers(&x->x_alist, 0, x->x_alist.l_n);
/* shift existing elements after 'index' to the right */
if (index < x->x_alist.l_n)
{
memmove(x->x_alist.l_vec + index + argc, x->x_alist.l_vec + index,
(x->x_alist.l_n - index) * sizeof(*x->x_alist.l_vec));
/* fix gpointers because of memmove() */
if (x->x_alist.l_npointer)
list_store_restore_gpointers(&x->x_alist, index + argc, x->x_alist.l_n - index);
alist_restore_gpointers(&x->x_alist, index + argc, x->x_alist.l_n - index);
}
/* finally copy new elements */
alist_copyin(&x->x_alist, s, argc, argv, index);
Expand Down Expand Up @@ -681,9 +681,9 @@ static void list_store_delete(t_list_store *x, t_floatarg f1, t_floatarg f2)
{
/* fix all gpointers in case resizebytes() has moved the alist in memory */
if (x->x_alist.l_vec != oldptr)
list_store_restore_gpointers(&x->x_alist, 0, x->x_alist.l_n - n);
alist_restore_gpointers(&x->x_alist, 0, x->x_alist.l_n - n);
else /* only fix gpointers after index (because of of memmove()) */
list_store_restore_gpointers(&x->x_alist, index, x->x_alist.l_n - index - n);
alist_restore_gpointers(&x->x_alist, index, x->x_alist.l_n - index - n);
}
x->x_alist.l_n -= n;
}
Expand Down

0 comments on commit 4e520c2

Please sign in to comment.