diff --git a/libs/lista.c b/libs/lista.c index 5362d1f4c6b7120ae2fb70f6d866051b9fce5684..3e0700c69600307c57ff3681697c89ac692908c5 100644 --- a/libs/lista.c +++ b/libs/lista.c @@ -1,4 +1,5 @@ #include <malloc.h> +#include <stdbool.h> #include "lista.h" #include "no.h" //--------------------------------------------------------------------------- @@ -51,10 +52,10 @@ Lista constroiLista(void) { // devolve 1 em caso de sucesso, // ou 0 em caso de falha -int destroiLista(Lista l, int destroi(void *)) { +bool destroiLista(Lista l, bool destroi(void *)) { No p; - int ok=1; + bool ok=true; while ( (p = primeiroNoLista(l)) ) { @@ -132,8 +133,8 @@ No insereUnicoLista(void *conteudo, Lista l) { // devolve 1, em caso de sucesso // 0, se rNo não for um No de l -int removeNo(struct Lista *l, struct No *rNo, int destroi(void *)) { - int r = 1; +bool removeNo(struct Lista *l, struct No *rNo, bool destroi(void *)) { + bool r = true; if (l->primeiro == rNo) { l->primeiro = getSucessorNo(rNo); if (destroi != NULL) { @@ -154,5 +155,5 @@ int removeNo(struct Lista *l, struct No *rNo, int destroi(void *)) { return r; } } - return 0; + return false; } diff --git a/libs/lista.h b/libs/lista.h index 43179ca736f1636465fe4bd8531ba9fe65256099..33eb81465ea3d46e242c1e18a4354a2c741c629d 100644 --- a/libs/lista.h +++ b/libs/lista.h @@ -1,6 +1,7 @@ #ifndef _LISTA_ #define _LISTA_ #include "no.h" +#include <stdbool.h> //----------------------------------------------------------------------------- // (apontador para) Lista encadeada @@ -49,16 +50,16 @@ Lista constroiLista(void); // // para cada nó n da Lista. // -// devolve 1 em caso de sucesso, -// ou 0 em caso de falha +// devolve true em caso de sucesso, +// ou false em caso de falha -int destroiLista(Lista l, int destroi(void *)); +bool destroiLista(Lista l, bool destroi(void *)); //------------------------------------------------------------------------------ // remove o No de endereço rNo de l // se destroi != NULL, executa destroi(conteudo(rNo)) -// devolve 1, em caso de sucesso -// 0, se rNo não for um No de l +// devolve true, em caso de sucesso +// false, se rNo não for um No de l -int removeNoLista(struct Lista *l, struct No *rNo, int destroi(void *)); +bool removeNoLista(struct Lista *l, struct No *rNo, bool destroi(void *)); #endif diff --git a/libs/vertice.c b/libs/vertice.c index 64dbdd773c15c623856612c604932033abfc67a3..35fb0e53c4f912260563da858843b7767ced071b 100644 --- a/libs/vertice.c +++ b/libs/vertice.c @@ -15,12 +15,12 @@ Vertice criaVertice() { return v; } -int destroiVertice(void *v) { +bool destroiVertice(void *v) { Vertice w = (Vertice) v; // Como os outros vértices também estão no grafo, deixamos isso a cargo dele destroiLista(w->pais, NULL); destroiLista(w->filhos, NULL); free(w); w = NULL; - return 1; + return true; } diff --git a/libs/vertice.h b/libs/vertice.h index 414e9cbb2ccf6fc80efd01cbd54b94ce24f8371b..9ee344e46b561b35965563d85fdb2fa74ccc535c 100644 --- a/libs/vertice.h +++ b/libs/vertice.h @@ -16,6 +16,6 @@ typedef struct Vertice *Vertice; Vertice criaVertice(); -int destroiVertice(void *v); +bool destroiVertice(void *v); #endif