-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlistaFrames.c
79 lines (66 loc) · 1.4 KB
/
listaFrames.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
lista_frames.c
Funções de controle da lista de frames
*/
#include "listaFrames.h"
lista_frames* CriaListaFrames(){
return NULL;
}
lista_frames* InsereInicioFrames(lista_frames* lista,frame *f){
lista_frames *novo = (lista_frames*) malloc(sizeof(lista_frames));
novo->f = f;
novo->prox = lista;
novo->ant = NULL;
if (lista!=NULL){
lista->ant = novo;
}
return novo;
}
lista_frames* InsereFimFrames(lista_frames* lista,frame *f){
lista_frames *novo = malloc(sizeof(lista_frames));
lista_frames *ant = NULL;
lista_frames *p = lista;
while(p!=NULL){
ant = p;
p=p->prox;
}
novo->f = f;
novo->prox = NULL;
novo->ant = ant;
ant->prox = novo;
return (lista);
}
lista_frames* RemoveInicioFrames(lista_frames* lista){
lista_frames* p=lista;
lista = p->prox;
if(lista!=NULL){
lista->ant = NULL;
}
free(p);
return (lista);
}
lista_frames* RemoveFimFrames(lista_frames* lista){
lista_frames *p=lista;
lista_frames *ant=NULL;
while (p!=NULL){
ant = p;
p=p->prox;
}
ant->ant->prox = NULL;
free(ant);
return (lista);
}
void ImprimeListaFrames(lista_frames *lista){
lista_frames *f;
for(f=lista; f!=NULL; f=f->prox){
printf("%04x\n\n", f->f->end_retorno);
}
}
void LiberaListaFrames(lista_frames *lista){
lista_frames *p=lista;
while(p!=NULL){
lista_frames *t = p->prox;
free(p);
p=t;
}
}