From dea629301a55a49507dc86fc412cad03d7d85af0 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Wed, 11 May 2011 21:51:17 +0000 Subject: [PATCH] Refactor gncOwnerCreate/Destroy into gncOwnerNew/Free to avoid confusion with similar gncCreate/Destroy functions, like gncVendorCreate, gncCustomerDestroy and so on. The type specific functions add or delete the owner from the book, while the generic one only allocated memory or freed memory to hold a generic owner. Changing the name makes it clear the generic and specific functions are not related. Note: this change may require a clean rebuild. I'm not sure if swig picks this up automatically. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20621 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/business/business-core/business-core.scm | 6 +++--- src/business/business-gnome/gnc-plugin-business.c | 8 ++++---- src/business/business-utils/business-options.scm | 2 +- src/engine/gncBusiness.c | 2 +- src/engine/gncOwner.c | 4 ++-- src/engine/gncOwner.h | 4 ++-- src/gnome-utils/gnc-tree-view-owner.c | 2 +- src/optional/python-bindings/gnucash_core.i | 4 ++-- src/plugins/bi_import/bi_import.c | 2 +- src/report/business-reports/aging.scm | 8 ++++---- src/report/business-reports/owner-report.scm | 4 ++-- 11 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/business/business-core/business-core.scm b/src/business/business-core/business-core.scm index 1caf53a766..9e1fa541e7 100644 --- a/src/business/business-core/business-core.scm +++ b/src/business/business-core/business-core.scm @@ -92,7 +92,7 @@ (define (gnc:owner-from-split split result-owner) (let* ((trans (xaccSplitGetParent split)) (invoice (gncInvoiceGetInvoiceFromTxn trans)) - (temp-owner (gncOwnerCreate)) + (temp-owner (gncOwnerNew)) (owner '())) (if (not (null? invoice)) @@ -117,10 +117,10 @@ (if (not (null? owner)) (begin (gncOwnerCopy (gncOwnerGetEndOwner owner) result-owner) - (gncOwnerDestroy temp-owner) + (gncOwnerFree temp-owner) result-owner) (begin - (gncOwnerDestroy temp-owner) + (gncOwnerFree temp-owner) '())))) diff --git a/src/business/business-gnome/gnc-plugin-business.c b/src/business/business-gnome/gnc-plugin-business.c index 4240efecec..a46ad4f8e2 100644 --- a/src/business/business-gnome/gnc-plugin-business.c +++ b/src/business/business-gnome/gnc-plugin-business.c @@ -398,13 +398,13 @@ gnc_plugin_business_init (GncPluginBusiness *plugin) GncPluginBusinessPrivate *priv; priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin); - priv->last_customer = gncOwnerCreate (); + priv->last_customer = gncOwnerNew (); gncOwnerInitCustomer (priv->last_customer, NULL); - priv->last_vendor = gncOwnerCreate (); + priv->last_vendor = gncOwnerNew (); gncOwnerInitVendor (priv->last_vendor, NULL); - priv->last_employee = gncOwnerCreate (); + priv->last_employee = gncOwnerNew (); gncOwnerInitEmployee (priv->last_employee, NULL); } @@ -804,7 +804,7 @@ gnc_plugin_business_cmd_test_init_data (GtkAction *action, GncCustomer *customer = gncCustomerCreate(book); GncAddress *address = gncCustomerGetAddr(customer); GncInvoice *invoice = gncInvoiceCreate(book); - GncOwner *owner = gncOwnerCreate(); + GncOwner *owner = gncOwnerNew(); GncJob *job = gncJobCreate(book); Account *root = gnc_book_get_root_account(book); Account *inc_acct = xaccMallocAccount(book); diff --git a/src/business/business-utils/business-options.scm b/src/business/business-utils/business-options.scm index e8a6560a77..dbe6ba7905 100644 --- a/src/business/business-utils/business-options.scm +++ b/src/business/business-utils/business-options.scm @@ -279,7 +279,7 @@ value-validator owner-type) - (let ((option-value (gncOwnerCreate))) + (let ((option-value (gncOwnerNew))) (define (convert-to-pair item) (if (pair? item) diff --git a/src/engine/gncBusiness.c b/src/engine/gncBusiness.c index 1da29a89ef..4653b79f7d 100644 --- a/src/engine/gncBusiness.c +++ b/src/engine/gncBusiness.c @@ -65,7 +65,7 @@ static void get_ownerlist_cb (QofInstance *inst, gpointer user_data) struct _get_list_userdata* data = user_data; if (!data->is_active_accessor_func || data->is_active_accessor_func(inst, NULL)) { - GncOwner *owner = gncOwnerCreate(); + GncOwner *owner = gncOwnerNew(); qofOwnerSetEntity(owner, inst); data->result = g_list_prepend(data->result, owner); } diff --git a/src/engine/gncOwner.c b/src/engine/gncOwner.c index 582e05d0fc..3dddf05237 100644 --- a/src/engine/gncOwner.c +++ b/src/engine/gncOwner.c @@ -46,7 +46,7 @@ #define GNC_OWNER_TYPE "owner-type" #define GNC_OWNER_GUID "owner-guid" -GncOwner * gncOwnerCreate (void) +GncOwner * gncOwnerNew (void) { GncOwner *o; @@ -55,7 +55,7 @@ GncOwner * gncOwnerCreate (void) return o; } -void gncOwnerDestroy (GncOwner *owner) +void gncOwnerFree (GncOwner *owner) { if (!owner) return; g_free (owner); diff --git a/src/engine/gncOwner.h b/src/engine/gncOwner.h index 79b4d04304..3093c147b5 100644 --- a/src/engine/gncOwner.h +++ b/src/engine/gncOwner.h @@ -176,8 +176,8 @@ KvpFrame* gncOwnerGetSlots(GncOwner* owner); * Normal C code has no need to ever use these two functions, and rather * can just use a GncOwner directly and just pass around a pointer to it. */ -GncOwner * gncOwnerCreate (void); -void gncOwnerDestroy (GncOwner *owner); +GncOwner * gncOwnerNew (void); +void gncOwnerFree (GncOwner *owner); #endif /* GNC_OWNER_H_ */ /** @} */ diff --git a/src/gnome-utils/gnc-tree-view-owner.c b/src/gnome-utils/gnc-tree-view-owner.c index 0e48c17377..915ea3daad 100644 --- a/src/gnome-utils/gnc-tree-view-owner.c +++ b/src/gnome-utils/gnc-tree-view-owner.c @@ -1561,7 +1561,7 @@ tree_restore_selected_row (GncTreeViewOwner *view, GncOwnerType owner_type, const gchar *owner_guid_str) { - GncOwner *owner=gncOwnerCreate(); + GncOwner *owner=gncOwnerNew(); QofBook *book; GncGUID owner_guid; diff --git a/src/optional/python-bindings/gnucash_core.i b/src/optional/python-bindings/gnucash_core.i index 571fdb473a..bafbada539 100644 --- a/src/optional/python-bindings/gnucash_core.i +++ b/src/optional/python-bindings/gnucash_core.i @@ -140,7 +140,7 @@ %typemap(in) GncOwner * { - GncOwner * temp_owner = gncOwnerCreate(); + GncOwner * temp_owner = gncOwnerNew(); void * pointer_to_real_thing; if ((SWIG_ConvertPtr($input, &pointer_to_real_thing, $descriptor(GncCustomer *), @@ -176,7 +176,7 @@ } %typemap(freearg) GncOwner * { - gncOwnerDestroy($1); + gncOwnerFree($1); } diff --git a/src/plugins/bi_import/bi_import.c b/src/plugins/bi_import/bi_import.c index 510b63fadf..f8019147da 100644 --- a/src/plugins/bi_import/bi_import.c +++ b/src/plugins/bi_import/bi_import.c @@ -552,7 +552,7 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book, // new invoice invoice = gncInvoiceCreate (book); gncInvoiceSetID (invoice, id); - owner = gncOwnerCreate (); + owner = gncOwnerNew (); if (g_ascii_strcasecmp (type, "BILL") == 0) gncOwnerInitVendor (owner, gnc_search_vendor_on_id (book, owner_id)); diff --git a/src/report/business-reports/aging.scm b/src/report/business-reports/aging.scm index 6047baa53a..793e6c0fa1 100644 --- a/src/report/business-reports/aging.scm +++ b/src/report/business-reports/aging.scm @@ -181,7 +181,7 @@ (define (do-update value) (let* ((transaction (xaccSplitGetParent split)) - (temp-owner (gncOwnerCreate)) + (temp-owner (gncOwnerNew)) (owner (gnc:owner-from-split split temp-owner))) (if (not (null? owner)) @@ -218,7 +218,7 @@ more than one currency. This report is not designed to cope with this possibili (process-payment company-info value)) (hash-set! hash guid company-info) (cons #t guid))) - (gncOwnerDestroy temp-owner)) + (gncOwnerFree temp-owner)) ;; if it's a new company (begin @@ -230,7 +230,7 @@ more than one currency. This report is not designed to cope with this possibili (hash-set! hash guid new-company)) (cons #t guid)))) ; else (no owner) - (gncOwnerDestroy temp-owner)))) + (gncOwnerFree temp-owner)))) ;; figure out if this split is part of a closed lot ;; also save the split value... @@ -655,7 +655,7 @@ totals to report currency") (gnc:owner-anchor-text owner) company-name)) monetary-list)) - (gncOwnerDestroy owner))) + (gncOwnerFree owner))) company-list) ;; add the totals diff --git a/src/report/business-reports/owner-report.scm b/src/report/business-reports/owner-report.scm index ffce7239c9..2fab06b2f3 100644 --- a/src/report/business-reports/owner-report.scm +++ b/src/report/business-reports/owner-report.scm @@ -834,14 +834,14 @@ account split query journal? double? title debit-string credit-string) - (let* ((temp-owner (gncOwnerCreate)) + (let* ((temp-owner (gncOwnerNew)) (owner (gnc:owner-from-split split temp-owner)) (res -1)) ;; XXX -- in this case we should create an error report (if (not (null? owner)) (set! res (gnc:owner-report-create owner account))) - (gncOwnerDestroy temp-owner) + (gncOwnerFree temp-owner) res)) (gnc:register-report-hook ACCT-TYPE-RECEIVABLE #t