Adiciona suporte a linha de dependentes.
[cascardo/declara.git] / lib / declaracao.c
index e4afe91..b1cfb55 100644 (file)
@@ -25,6 +25,7 @@
 #include "isento.h"
 #include "pagamento.h"
 #include "bem.h"
+#include "dependente.h"
 #include "pmhash.h"
 
 struct declaracao * declaracao_new(int ano)
@@ -47,6 +48,9 @@ struct declaracao * declaracao_new(int ano)
        dec->bens = list_new();
        if (!dec->bens)
                goto out_bens;
+       dec->dependentes = list_new();
+       if (!dec->dependentes)
+               goto out_dependentes;
        dec->totais = pmhash_new();
        if (!dec->totais)
                goto out_totais;
@@ -56,6 +60,8 @@ struct declaracao * declaracao_new(int ano)
        dec->tipo = SIMPLES;
        return dec;
 out_totais:
+       list_free(dec->dependentes, dependente_free);
+out_dependentes:
        list_free(dec->bens, bem_free);
 out_bens:
        list_free(dec->pagamentos, pagamento_free);
@@ -90,6 +96,7 @@ void declaracao_free(struct declaracao *dec)
        list_free(dec->isentos, isento_free);
        list_free(dec->pagamentos, pagamento_free);
        list_free(dec->bens, bem_free);
+       list_free(dec->dependentes, dependente_free);
        pmhash_del(dec->totais);
        sistema_free(dec);
        free(dec);