commit
This commit is contained in:
parent
3e73277764
commit
50efd5be5a
6 changed files with 90 additions and 19 deletions
60
conf.c
60
conf.c
|
@ -44,6 +44,36 @@ void addConf(ptConf confChain, int id, char title[], char speaker[], int day, in
|
|||
px -> next -> next = NULL;
|
||||
}
|
||||
|
||||
void removeConf(ptConf confChain, int id) {
|
||||
ptConf px = confChain;
|
||||
|
||||
if (px -> next -> next == NULL) {
|
||||
free(px -> next);
|
||||
px -> next = NULL;
|
||||
} else if (px -> id == id) {
|
||||
px -> id = px -> next -> id;
|
||||
strcpy(px -> title, px -> next -> title);
|
||||
strcpy(px -> speaker, px -> next -> speaker);
|
||||
px -> day = px -> next -> day;
|
||||
px -> month = px -> next -> month;
|
||||
px -> year = px -> next -> year;
|
||||
|
||||
ptConf tmp = px -> next;
|
||||
px -> next = px -> next -> next;
|
||||
free(tmp);
|
||||
} else {
|
||||
while (px -> next != NULL && px -> next -> id != id) {
|
||||
px = px -> next;
|
||||
}
|
||||
|
||||
if (px -> next -> id == id) {
|
||||
ptConf tmp = px -> next;
|
||||
px -> next = px -> next -> next;
|
||||
free(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int findListenerId(ptListener listenerChain) {
|
||||
ptListener px = listenerChain;
|
||||
int max = 0;
|
||||
|
@ -83,4 +113,34 @@ void addListener(ptListener listenerChain, int id, char name[], int age, int lev
|
|||
px -> next = (ptListener) malloc(sizeof(tListener));
|
||||
px -> next -> next = NULL;
|
||||
px -> next -> prev = px;
|
||||
}
|
||||
|
||||
void removeListener(ptListener listenerChain, int id) {
|
||||
ptListener px = listenerChain;
|
||||
|
||||
if (px -> next -> next == NULL) {
|
||||
free(px -> next);
|
||||
px -> next = NULL;
|
||||
} else if (px -> id == id) {
|
||||
px -> id = px -> next -> id;
|
||||
strcpy(px -> name, px -> next -> name);
|
||||
px -> age = px -> next -> age;
|
||||
px -> level = px -> next -> level;
|
||||
|
||||
ptListener tmp = px -> next;
|
||||
px -> next = px -> next -> next;
|
||||
px -> next -> prev = px;
|
||||
free(tmp);
|
||||
} else {
|
||||
while (px -> next != NULL && px -> next -> id != id) {
|
||||
px = px -> next;
|
||||
}
|
||||
|
||||
if (px -> next -> id == id) {
|
||||
ptListener tmp = px -> next;
|
||||
px -> next = px -> next -> next;
|
||||
px -> next -> prev = px;
|
||||
free(tmp);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue