Utiliza dicionĂ¡rio de totais no lugar de totalrendimento.
[cascardo/declara.git] / declaracao.c
index 2fc3f0a..d52be42 100644 (file)
@@ -31,16 +31,21 @@ struct declaracao * declaracao_new(int ano)
        memset(dec, 0, sizeof(*dec));
        dec->ano = ano;
        dec->rendimento = list_new();
-       if (!dec->rendimento) {
-               free(dec);
-               return NULL;
-       }
-       dec->totalrendimento = 0;
+       if (!dec->rendimento)
+               goto out_rendimento;
+       dec->totais = pmhash_new();
+       if (!dec->totais)
+               goto out_totais;
        dec->pago = 0;
        dec->devido = 0;
        dec->restituicao = 0;
        dec->tipo = SIMPLES;
        return dec;
+out_totais:
+       list_free(dec->rendimento, rendimento_free);
+out_rendimento:
+       free(dec);
+       return NULL;
 }
 
 void declaracao_free(struct declaracao *dec)
@@ -62,5 +67,6 @@ void declaracao_free(struct declaracao *dec)
        if (dec->dvconta)
                free(dec->dvconta);
        list_free(dec->rendimento, rendimento_free);
+       pmhash_del(dec->totais);
        free(dec);
 }