center_t operations

This commit is contained in:
Adrien Bourmault 2021-06-14 19:00:44 +02:00
parent 9248f8176b
commit 6c7a46d3cd
No known key found for this signature in database
GPG Key ID: 6EB408FE0ACEC664
1 changed files with 7 additions and 12 deletions

View File

@ -50,25 +50,20 @@ static inline void centerAssign(Center_t *center, int x, int y, int z)
static inline Center_t *centerAdd(Center_t *anyCenter, Center_t *newCenter)
{
Center_t *temp = anyCenter->next;
anyCenter->next = newCenter;
newCenter->next = temp;
newCenter->prev = anyCenter;
if (temp) {
temp->prev = newCenter;
if (anyCenter->next) {
anyCenter->next->prev = newCenter;
}
newCenter->next = anyCenter->next;
anyCenter->next = newCenter;
newCenter->prev = anyCenter;
return newCenter;
}
static inline void centerRemove(Center_t *oldCenter)
{
Center_t *prev = oldCenter->prev;
Center_t *next = oldCenter->next;
prev->next = next->prev;
next->prev = prev->next;
oldCenter->prev->next = oldCenter->next;
oldCenter->next->prev = oldCenter->prev;
free(oldCenter);
}