]> Dogcows Code - chaz/homebank/blobdiff - src/hb-archive.c
Merge branch 'master' into ext-perl
[chaz/homebank] / src / hb-archive.c
index 890cd7f5c15bae7fb397a3f4884b68bcbfef3433..db3b10188739f87895cadb4e58bef5d746c8c9ca 100644 (file)
@@ -21,6 +21,9 @@
 #include "hb-archive.h"
 #include "hb-split.h"
 
+#include "ext.h"
+#include "refcount.h"
+
 /****************************************************************************/
 /* Debug macros                                                             */
 /****************************************************************************/
@@ -40,7 +43,7 @@ Archive *da_archive_malloc(void)
 {
 Archive *item;
 
-       item = g_malloc0(sizeof(Archive));
+       item = rc_alloc(sizeof(Archive));
        item->key = 1;
        return item;
 }
@@ -48,7 +51,7 @@ Archive *item;
 
 Archive *da_archive_clone(Archive *src_item)
 {
-Archive *new_item = g_memdup(src_item, sizeof(Archive));
+Archive *new_item = rc_dup(src_item, sizeof(Archive));
 
        if(new_item)
        {
@@ -71,13 +74,13 @@ Archive *new_item = g_memdup(src_item, sizeof(Archive));
 
 void da_archive_free(Archive *item)
 {
-       if(item != NULL)
+       if(rc_unref(item))
        {
                if(item->memo != NULL)
                        g_free(item->memo);
                if(item->splits != NULL)
                        da_split_destroy(item->splits);
-               g_free(item);
+               rc_free(item);
        }
 }
 
@@ -145,10 +148,10 @@ guint32 max_key = 0;
        {
        Archive *item = tmplist->data;
 
-               max_key = MAX(item->key, max_key);              
+               max_key = MAX(item->key, max_key);
                tmplist = g_list_next(tmplist);
        }
-       
+
        return max_key;
 }
 
@@ -191,7 +194,7 @@ guint nbsplit;
                GLOBALS->changes_count++;
        }
 
-       //#1340142 check split category         
+       //#1340142 check split category
        if( item->splits != NULL )
        {
                nbsplit = da_splits_consistency(item->splits);
@@ -203,7 +206,7 @@ guint nbsplit;
                        GLOBALS->changes_count++;
                }
        }
-       
+
        // check payee exists
        pay = da_pay_get(item->kpay);
        if(pay == NULL)
@@ -253,7 +256,7 @@ Archive *da_archive_init_from_transaction(Archive *arc, Transaction *txn)
        arc->splits  = da_splits_clone(txn->splits);
        if( da_splits_length (arc->splits) > 0 )
                arc->flags |= OF_SPLIT; //Flag that Splits are active
-       
+
        return arc;
 }
 
@@ -289,7 +292,7 @@ guint32 nextpostdate = nextdate;
 
        /* get the final post date and free */
        nextpostdate = g_date_get_julian(tmpdate);
-       
+
        return nextpostdate;
 }
 
@@ -317,7 +320,7 @@ gint shift;
 
 
        finalpostdate = postdate;
-       
+
        tmpdate = g_date_new_julian(finalpostdate);
        /* manage weekend exception */
        if( arc->weekend > 0 )
@@ -344,11 +347,11 @@ gint shift;
                        }
                }
        }
-       
+
        /* get the final post date and free */
        finalpostdate = g_date_get_julian(tmpdate);
        g_date_free(tmpdate);
-       
+
        return finalpostdate;
 }
 
@@ -392,10 +395,10 @@ guint32 nblate = 0;
 
        if(arc->flags & OF_LIMIT)
                nblate = MIN(nblate, arc->limit);
-       
+
        nblate = MIN(nblate, 11);
        */
-       
+
 
        // pre 5.1 way
        post_date = g_date_new();
@@ -451,7 +454,7 @@ gushort lastday;
                        }
 
                        arc->daygap = CLAMP(lastday - g_date_get_day(post_date), 0, 3);
-               
+
                        DB( g_print(" daygap is %d\n", arc->daygap) );
                }
                else
@@ -488,10 +491,10 @@ GDate *today, *maxdate;
        DB( g_print("\n[scheduled] date_get_post_max\n") );
 
        //add until xx of the next month (excluded)
-       if(GLOBALS->auto_smode == 0)    
+       if(GLOBALS->auto_smode == 0)
        {
                DB( g_print(" - max is %d of next month\n", GLOBALS->auto_weekday) );
-               
+
                today = g_date_new_julian(GLOBALS->today);
 
                //we compute user xx weekday of next month
@@ -499,9 +502,9 @@ GDate *today, *maxdate;
                g_date_set_day(maxdate, GLOBALS->auto_weekday);
                if(g_date_get_day (today) >= GLOBALS->auto_weekday)
                        g_date_add_months(maxdate, 1);
-               
+
                nbdays = g_date_days_between(today, maxdate);
-       
+
                g_date_free(maxdate);
                g_date_free(today);
        }
@@ -532,7 +535,7 @@ Transaction *txn;
        maxpostdate = scheduled_date_get_post_max();
 
        txn = da_transaction_malloc();
-       
+
        list = g_list_first(GLOBALS->arc_list);
        while (list != NULL)
        {
@@ -552,7 +555,7 @@ Transaction *txn;
                                while(mydate < maxpostdate)
                                {
                                        DB( hb_print_date(mydate, arc->memo) );
-                                       
+
                                        da_transaction_init_from_template(txn, arc);
                                        txn->date = scheduled_get_postdate(arc, mydate);
                                        /* todo: ? fill in cheque number */
@@ -578,7 +581,7 @@ nextarchive:
        }
 
        da_transaction_free (txn);
-       
+
        return count;
 }
 
This page took 0.025546 seconds and 4 git commands to generate.