Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int add_testimone (Testimone* t, Element** l)
- {
- Element *temp;
- Element *e = new_element (t);
- /*inserimento in una lista non inizializzata*/
- if (*l == NULL)
- {
- *l=my_malloc(sizeof (Element*));
- e->next = NULL;
- *l=e;
- return 1;
- }
- temp = *l;
- /*inserimento al primo posto*/
- if (strcmp(e->key, (*l)->key) < 0)
- {
- head_insert(e,l);
- return 1;
- }
- while (1)
- {
- if (temp->key == e->key)
- {
- free(e);
- return 0;
- }
- /*inserimento nell'ultima posizione*/
- if (temp->next == NULL)
- {
- temp->next = e;
- return 1;
- }
- /*inserimento in mezzo alla lista*/
- if (strcmp(e->key, temp->next->key)<0)
- {
- e->next = temp->next;
- temp->next = e;
- return 1;
- }
- temp = temp->next;
- }
- }
Add Comment
Please, Sign In to add comment