Suporta bens móveis.
[cascardo/declara.git] / lib / declaracao.c
index 53ff1e4..4c5f188 100644 (file)
@@ -22,6 +22,7 @@
 #include "list.h"
 #include "rendimento.h"
 #include "pagamento.h"
+#include "bem.h"
 #include "pmhash.h"
 
 struct declaracao * declaracao_new(int ano)
@@ -38,6 +39,9 @@ struct declaracao * declaracao_new(int ano)
        dec->pagamentos = list_new();
        if (!dec->pagamentos)
                goto out_pagamentos;
+       dec->bens = list_new();
+       if (!dec->bens)
+               goto out_bens;
        dec->totais = pmhash_new();
        if (!dec->totais)
                goto out_totais;
@@ -47,6 +51,8 @@ struct declaracao * declaracao_new(int ano)
        dec->tipo = SIMPLES;
        return dec;
 out_totais:
+       list_free(dec->bens, bem_free);
+out_bens:
        list_free(dec->pagamentos, pagamento_free);
 out_pagamentos:
        list_free(dec->rendimento, rendimento_free);
@@ -75,6 +81,7 @@ void declaracao_free(struct declaracao *dec)
                free(dec->dvconta);
        list_free(dec->rendimento, rendimento_free);
        list_free(dec->pagamentos, pagamento_free);
+       list_free(dec->bens, bem_free);
        pmhash_del(dec->totais);
        free(dec);
 }