This commit is contained in:
Lukian LEIZOUR 2023-11-29 22:55:40 +01:00
parent bd738652a5
commit 031b51a916
10 changed files with 172 additions and 146 deletions

View file

@ -119,28 +119,17 @@ void removeConf(ptConf confChain, int id)
{
ptConf px = confChain;
if (px->next->next == NULL)
if (px->next == NULL)
{
return;
}
else if (px->next->next == NULL)
{
ptListenerList py = px->listeners;
while (py->next != NULL)
{
ptConfList pz = py->listener->confs;
while (pz->next != NULL)
{
if (pz->next->next)
pz = pz->next;
}
py = py->next;
}
free(px->next);
px->next = NULL;
}
else if (px->id == id)
else if (px->id == id && px->next->next != NULL)
{
px->id = px->next->id;
strcpy(px->title, px->next->title);
@ -226,8 +215,11 @@ int addListener(ptListener listenerChain, int id, char name[], int age, int leve
void removeListener(ptListener listenerChain, int id)
{
ptListener px = listenerChain;
if (px->next->next == NULL)
if (px->next == NULL)
{
return;
}
else if (px->id == id && px->next->next == NULL)
{
free(px->next);
px->next = NULL;
@ -276,11 +268,52 @@ void addConfToConfList(ptConfList confList, ptConf conf, int grade)
px->next->next = NULL;
}
void removeConfFromConfList(ptConf confChain, ptConfList confList, ptConf conf)
{
if (confList->next == NULL)
{
return;
}
else if (confList->next->next == NULL && confList->conf == conf)
{
free(confList->next);
confList->next = NULL;
}
else if (confList->conf == conf && confList->next->next != NULL)
{
confList->conf = confList->next->conf;
confList->grade = confList->next->grade;
ptConfList tmp = confList->next->next;
free(confList->next);
confList->next = tmp;
}
else
{
ptConfList px = confList;
while (px->next != NULL && px->next->conf != conf)
{
if (confChain == conf && px->conf == conf->next) {
px->conf
}
px = px->next;
}
if (px->next->conf == conf) {
ptConfList tmp = px->next->next;
free(px->next);
px->next = tmp;
}
}
}
void printConfList(ptConfList confList)
{
ptConfList px = confList;
printf("Participation aux conferences : ");
printf(" Participation aux conferences : ");
while (px->next != NULL)
{
printf("%s(%d) ", px->conf->title, px->grade);