[Gnucash-changes] Patch from Chris Shoemaker to convert all the
string cache users to use
David Hampton
hampton at cvs.gnucash.org
Fri Oct 14 08:55:22 EDT 2005
Log Message:
-----------
Patch from Chris Shoemaker to convert all the string cache users to
use the public access functions. Consolidate all the CACHE_INSERT and
CACHE_REMOVE macros into one place.
Tags:
----
gnucash-gnome2-dev
Modified Files:
--------------
gnucash:
ChangeLog
gnucash/src/app-utils:
gnc-component-manager.c
gnucash/src/business/business-core:
gncAddress.c
gncBillTerm.c
gncCustomer.c
gncEmployee.c
gncEntry.c
gncInvoice.c
gncJob.c
gncOrder.c
gncTaxTable.c
gncVendor.c
gnucash/src/business/business-core/test:
test-customer.c
test-employee.c
test-job.c
test-vendor.c
gnucash/src/engine:
Transaction.c
gnc-commodity.c
gnc-engine.c
gnc-pricedb.c
kvp_frame.c
qofid.c
qofquery-deserial.c
gnucash/src/engine/test:
test-commodities.c
gnucash/src/gnome-utils:
QuickFill.c
Revision Data
-------------
Index: ChangeLog
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/ChangeLog,v
retrieving revision 1.1487.2.335
retrieving revision 1.1487.2.336
diff -LChangeLog -LChangeLog -u -r1.1487.2.335 -r1.1487.2.336
--- ChangeLog
+++ ChangeLog
@@ -1,5 +1,46 @@
2005-10-14 David Hampton <hampton at employees.org>
+ * src/app-utils/gnc-component-manager.c:
+ * src/business/business-core/gncAddress.c:
+ * src/business/business-core/gncBillTerm.c:
+ * src/business/business-core/gncCustomer.c:
+ * src/business/business-core/gncEmployee.c:
+ * src/business/business-core/gncEntry.c:
+ * src/business/business-core/gncInvoice.c:
+ * src/business/business-core/gncJob.c:
+ * src/business/business-core/gncOrder.c:
+ * src/business/business-core/gncTaxTable.c:
+ * src/business/business-core/gncVendor.c:
+ * src/business/business-core/test/test-customer.c:
+ * src/business/business-core/test/test-employee.c:
+ * src/business/business-core/test/test-job.c:
+ * src/business/business-core/test/test-vendor.c:
+ * src/engine/Transaction.c:
+ * src/engine/gnc-commodity.c:
+ * src/engine/gnc-engine.c:
+ * src/engine/gnc-pricedb.c:
+ * src/engine/kvp_frame.c:
+ * src/engine/qofid.c:
+ * src/engine/qofquery-deserial.c:
+ * src/engine/test/test-commodities.c:
+ * src/gnome-utils/QuickFill.c: Patch from Chris Shoemaker to
+ convert all the string cache users to use the public access
+ functions. Consolidate all the CACHE_INSERT and CACHE_REMOVE
+ macros into one place.
+
+ * src/engine/gnc-engine-util.[ch]: Patch from Chris Shoemaker to
+ privatize the gnucash string cache code and force all usage
+ through gnc_string_cache_{remove,insert}() functions. This makes
+ debugging various uses (and misuses) of the cache easier.
+
+ * src/engine/qofquery-deserial.c: Patch from Chris Shoemaker to
+ annotate a possible bug.
+
+ * src/report/report-system/commodity-utilities.scm: Patch from
+ Chris Shoemaker to change the collector handling of invalid
+ exchange functions. Add a warning about dangerous usage of
+ gnc:exchange-if-same.
+
* src/backend/postgres/PostgresBackend.c:
* src/backend/postgres/checkpoint.c:
* src/backend/postgres/events.c:
Index: gncEmployee.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncEmployee.c,v
retrieving revision 1.15.4.8
retrieving revision 1.15.4.9
diff -Lsrc/business/business-core/gncEmployee.c -Lsrc/business/business-core/gncEmployee.c -u -r1.15.4.8 -r1.15.4.9
--- src/business/business-core/gncEmployee.c
+++ src/business/business-core/gncEmployee.c
@@ -59,9 +59,6 @@
#define _GNC_MOD_NAME GNC_ID_EMPLOYEE
-#define CACHE_INSERT(str) g_cache_insert(gnc_engine_get_string_cache(), (gpointer)(str));
-#define CACHE_REMOVE(str) g_cache_remove(gnc_engine_get_string_cache(), (str));
-
G_INLINE_FUNC void mark_employee (GncEmployee *employee);
void mark_employee (GncEmployee *employee)
{
Index: gncInvoice.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncInvoice.c,v
retrieving revision 1.56.4.15
retrieving revision 1.56.4.16
diff -Lsrc/business/business-core/gncInvoice.c -Lsrc/business/business-core/gncInvoice.c -u -r1.56.4.15 -r1.56.4.16
--- src/business/business-core/gncInvoice.c
+++ src/business/business-core/gncInvoice.c
@@ -76,9 +76,6 @@
#define GNC_INVOICE_ID "gncInvoice"
#define GNC_INVOICE_GUID "invoice-guid"
-#define CACHE_INSERT(str) g_cache_insert(gnc_engine_get_string_cache(), (gpointer)(str));
-#define CACHE_REMOVE(str) g_cache_remove(gnc_engine_get_string_cache(), (str));
-
#define SET_STR(obj, member, str) { \
char * tmp; \
\
Index: gncCustomer.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncCustomer.c,v
retrieving revision 1.20.4.11
retrieving revision 1.20.4.12
diff -Lsrc/business/business-core/gncCustomer.c -Lsrc/business/business-core/gncCustomer.c -u -r1.20.4.11 -r1.20.4.12
--- src/business/business-core/gncCustomer.c
+++ src/business/business-core/gncCustomer.c
@@ -76,9 +76,6 @@
/* ============================================================== */
/* misc inline funcs */
-#define CACHE_INSERT(str) g_cache_insert(gnc_engine_get_string_cache(), (gpointer)(str));
-#define CACHE_REMOVE(str) g_cache_remove(gnc_engine_get_string_cache(), (str));
-
G_INLINE_FUNC void mark_customer (GncCustomer *customer);
void mark_customer (GncCustomer *customer)
{
Index: gncVendor.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncVendor.c,v
retrieving revision 1.21.4.8
retrieving revision 1.21.4.9
diff -Lsrc/business/business-core/gncVendor.c -Lsrc/business/business-core/gncVendor.c -u -r1.21.4.8 -r1.21.4.9
--- src/business/business-core/gncVendor.c
+++ src/business/business-core/gncVendor.c
@@ -65,9 +65,6 @@
/* ============================================================ */
/* Misc inline funcs */
-#define CACHE_INSERT(str) g_cache_insert(gnc_engine_get_string_cache(), (gpointer)(str));
-#define CACHE_REMOVE(str) g_cache_remove(gnc_engine_get_string_cache(), (str));
-
G_INLINE_FUNC void mark_vendor (GncVendor *vendor);
void mark_vendor (GncVendor *vendor)
{
Index: gncJob.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncJob.c,v
retrieving revision 1.18.4.10
retrieving revision 1.18.4.11
diff -Lsrc/business/business-core/gncJob.c -Lsrc/business/business-core/gncJob.c -u -r1.18.4.10 -r1.18.4.11
--- src/business/business-core/gncJob.c
+++ src/business/business-core/gncJob.c
@@ -54,9 +54,6 @@
/* ================================================================== */
/* misc inline functions */
-#define CACHE_INSERT(str) g_cache_insert(gnc_engine_get_string_cache(), (gpointer)(str));
-#define CACHE_REMOVE(str) g_cache_remove(gnc_engine_get_string_cache(), (str));
-
G_INLINE_FUNC void mark_job (GncJob *job);
void mark_job (GncJob *job)
{
Index: gncBillTerm.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncBillTerm.c,v
retrieving revision 1.6.4.8
retrieving revision 1.6.4.9
diff -Lsrc/business/business-core/gncBillTerm.c -Lsrc/business/business-core/gncBillTerm.c -u -r1.6.4.8 -r1.6.4.9
--- src/business/business-core/gncBillTerm.c
+++ src/business/business-core/gncBillTerm.c
@@ -66,9 +66,6 @@
#define _GNC_MOD_NAME GNC_ID_BILLTERM
-#define CACHE_INSERT(str) g_cache_insert(gnc_engine_get_string_cache(), (gpointer)(str));
-#define CACHE_REMOVE(str) g_cache_remove(gnc_engine_get_string_cache(), (str));
-
#define SET_STR(obj, member, str) { \
char * tmp; \
\
Index: gncEntry.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncEntry.c,v
retrieving revision 1.32.4.9
retrieving revision 1.32.4.10
diff -Lsrc/business/business-core/gncEntry.c -Lsrc/business/business-core/gncEntry.c -u -r1.32.4.9 -r1.32.4.10
--- src/business/business-core/gncEntry.c
+++ src/business/business-core/gncEntry.c
@@ -156,9 +156,6 @@
#define _GNC_MOD_NAME GNC_ID_ENTRY
-#define CACHE_INSERT(str) g_cache_insert(gnc_engine_get_string_cache(), (gpointer)(str));
-#define CACHE_REMOVE(str) g_cache_remove(gnc_engine_get_string_cache(), (str));
-
#define SET_STR(obj, member, str) { \
char * tmp; \
\
Index: gncAddress.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncAddress.c,v
retrieving revision 1.4.4.10
retrieving revision 1.4.4.11
diff -Lsrc/business/business-core/gncAddress.c -Lsrc/business/business-core/gncAddress.c -u -r1.4.4.10 -r1.4.4.11
--- src/business/business-core/gncAddress.c
+++ src/business/business-core/gncAddress.c
@@ -52,9 +52,6 @@
#define _GNC_MOD_NAME GNC_ADDRESS_MODULE_NAME
-#define CACHE_INSERT(str) g_cache_insert(gnc_engine_get_string_cache(), (gpointer)(str));
-#define CACHE_REMOVE(str) g_cache_remove(gnc_engine_get_string_cache(), (str));
-
G_INLINE_FUNC void mark_address (GncAddress *address);
void mark_address (GncAddress *address)
{
Index: gncTaxTable.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncTaxTable.c,v
retrieving revision 1.9.4.8
retrieving revision 1.9.4.9
diff -Lsrc/business/business-core/gncTaxTable.c -Lsrc/business/business-core/gncTaxTable.c -u -r1.9.4.8 -r1.9.4.9
--- src/business/business-core/gncTaxTable.c
+++ src/business/business-core/gncTaxTable.c
@@ -131,9 +131,6 @@
#define _GNC_MOD_NAME GNC_ID_TAXTABLE
-#define CACHE_INSERT(str) g_cache_insert(gnc_engine_get_string_cache(), (gpointer)(str));
-#define CACHE_REMOVE(str) g_cache_remove(gnc_engine_get_string_cache(), (str));
-
#define SET_STR(obj, member, str) { \
char * tmp; \
\
Index: gncOrder.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncOrder.c,v
retrieving revision 1.23.4.9
retrieving revision 1.23.4.10
diff -Lsrc/business/business-core/gncOrder.c -Lsrc/business/business-core/gncOrder.c -u -r1.23.4.9 -r1.23.4.10
--- src/business/business-core/gncOrder.c
+++ src/business/business-core/gncOrder.c
@@ -57,9 +57,6 @@
#define _GNC_MOD_NAME GNC_ID_ORDER
-#define CACHE_INSERT(str) g_cache_insert(gnc_engine_get_string_cache(), (gpointer)(str));
-#define CACHE_REMOVE(str) g_cache_remove(gnc_engine_get_string_cache(), (str));
-
#define SET_STR(obj, member, str) { \
char * tmp; \
\
Index: qofquery-deserial.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofquery-deserial.c,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -Lsrc/engine/qofquery-deserial.c -Lsrc/engine/qofquery-deserial.c -u -r1.1.2.4 -r1.1.2.5
--- src/engine/qofquery-deserial.c
+++ src/engine/qofquery-deserial.c
@@ -33,11 +33,6 @@
#include "qofquerycore-p.h"
#include "gnc-engine-util.h"
-#define CACHE_INSERT(str) \
- g_cache_insert(gnc_engine_get_string_cache(), (gpointer)(str))
-#define CACHE_REMOVE(str) \
- g_cache_remove(gnc_engine_get_string_cache(), (gpointer)(str))
-
/* =========================================================== */
#define GET_TEXT(node) ({ \
Index: kvp_frame.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/kvp_frame.c,v
retrieving revision 1.30.4.11
retrieving revision 1.30.4.12
diff -Lsrc/engine/kvp_frame.c -Lsrc/engine/kvp_frame.c -u -r1.30.4.11 -r1.30.4.12
--- src/engine/kvp_frame.c
+++ src/engine/kvp_frame.c
@@ -43,6 +43,8 @@
* (gnc_string_cache), as it is very likely we will see the
* same keys over and over again */
+/* TODO: set the cache handling functions with hash_table_new_full */
+
struct _KvpFrame
{
GHashTable * hash;
@@ -113,7 +115,7 @@
static void
kvp_frame_delete_worker(gpointer key, gpointer value, gpointer user_data)
{
- g_cache_remove(gnc_engine_get_string_cache(), key);
+ gnc_string_cache_remove(key);
kvp_value_delete((KvpValue *)value);
}
@@ -148,7 +150,7 @@
{
KvpFrame * dest = (KvpFrame *)user_data;
g_hash_table_insert(dest->hash,
- (gpointer)g_cache_insert(gnc_engine_get_string_cache(), key),
+ gnc_string_cache_insert(key),
(gpointer)kvp_value_copy(value));
}
@@ -189,7 +191,7 @@
if(key_exists)
{
g_hash_table_remove(frame->hash, slot);
- g_cache_remove(gnc_engine_get_string_cache(), orig_key);
+ gnc_string_cache_remove(orig_key);
}
else
{
@@ -199,8 +201,7 @@
if(new_value)
{
g_hash_table_insert(frame->hash,
- g_cache_insert(gnc_engine_get_string_cache(),
- (gpointer) slot),
+ gnc_string_cache_insert((gpointer) slot),
new_value);
}
@@ -1745,6 +1746,7 @@
break;
case KVP_TYPE_GUID:
+ /* THREAD-UNSAFE */
ctmp = guid_to_string(kvp_value_get_guid(val));
tmp2 = g_strdup_printf("KVP_VALUE_GUID(%s)", ctmp ? ctmp : "");
return tmp2;
Index: qofid.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofid.c,v
retrieving revision 1.3.2.9
retrieving revision 1.3.2.10
diff -Lsrc/engine/qofid.c -Lsrc/engine/qofid.c -u -r1.3.2.9 -r1.3.2.10
--- src/engine/qofid.c
+++ src/engine/qofid.c
@@ -32,9 +32,6 @@
#include "gnc-trace.h"
#include "gnc-engine-util.h"
-#define CACHE_INSERT(str) g_cache_insert(gnc_engine_get_string_cache(), (gpointer)(str));
-#define CACHE_REMOVE(str) g_cache_remove(gnc_engine_get_string_cache(), (gpointer)(str));
-
static QofLogModule log_module = QOF_MOD_ENGINE;
struct QofCollection_s
Index: Transaction.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/Transaction.c,v
retrieving revision 1.261.4.19
retrieving revision 1.261.4.20
diff -Lsrc/engine/Transaction.c -Lsrc/engine/Transaction.c -u -r1.261.4.19 -r1.261.4.20
--- src/engine/Transaction.c
+++ src/engine/Transaction.c
@@ -101,8 +101,8 @@
split->parent = NULL;
split->lot = NULL;
- split->action = g_cache_insert(gnc_engine_get_string_cache(), "");
- split->memo = g_cache_insert(gnc_engine_get_string_cache(), "");
+ split->action = gnc_string_cache_insert("");
+ split->memo = gnc_string_cache_insert("");
split->reconciled = NREC;
split->amount = gnc_numeric_zero();
split->value = gnc_numeric_zero();
@@ -168,8 +168,8 @@
split->acc = s->acc;
split->lot = s->lot;
- split->memo = g_cache_insert (gnc_engine_get_string_cache(), s->memo);
- split->action = g_cache_insert (gnc_engine_get_string_cache(), s->action);
+ split->memo = gnc_string_cache_insert(s->memo);
+ split->action = gnc_string_cache_insert(s->action);
split->kvp_data = kvp_frame_copy (s->kvp_data);
@@ -196,8 +196,8 @@
split->book = s->book;
split->parent = NULL;
- split->memo = g_cache_insert(gnc_engine_get_string_cache(), s->memo);
- split->action = g_cache_insert(gnc_engine_get_string_cache(), s->action);
+ split->memo = gnc_string_cache_insert(s->memo);
+ split->action = gnc_string_cache_insert(s->action);
split->kvp_data = kvp_frame_copy(s->kvp_data);
split->reconciled = s->reconciled;
split->date_reconciled = s->date_reconciled;
@@ -260,8 +260,8 @@
PERR ("double-free %p", split);
return;
}
- g_cache_remove(gnc_engine_get_string_cache(), split->memo);
- g_cache_remove(gnc_engine_get_string_cache(), split->action);
+ gnc_string_cache_remove(split->memo);
+ gnc_string_cache_remove(split->action);
kvp_frame_delete (split->kvp_data);
split->kvp_data = NULL;
@@ -826,8 +826,8 @@
{
ENTER ("trans=%p", trans);
/* Fill in some sane defaults */
- trans->num = g_cache_insert(gnc_engine_get_string_cache(), "");
- trans->description = g_cache_insert(gnc_engine_get_string_cache(), "");
+ trans->num = gnc_string_cache_insert("");
+ trans->description = gnc_string_cache_insert("");
trans->common_currency = NULL;
trans->splits = NULL;
@@ -939,8 +939,8 @@
trans = g_new0 (Transaction, 1);
- trans->num = g_cache_insert (gnc_engine_get_string_cache(), t->num);
- trans->description = g_cache_insert (gnc_engine_get_string_cache(), t->description);
+ trans->num = gnc_string_cache_insert (t->num);
+ trans->description = gnc_string_cache_insert (t->description);
trans->splits = g_list_copy (t->splits);
for (node = trans->splits; node; node = node->next)
@@ -987,8 +987,8 @@
trans->date_entered = t->date_entered;
trans->date_posted = t->date_posted;
- trans->num = g_cache_insert (gnc_engine_get_string_cache(), t->num);
- trans->description = g_cache_insert (gnc_engine_get_string_cache(), t->description);
+ trans->num = gnc_string_cache_insert (t->num);
+ trans->description = gnc_string_cache_insert (t->description);
trans->common_currency = t->common_currency;
trans->version = t->version;
trans->version_check = t->version_check;
@@ -1038,8 +1038,8 @@
trans->splits = NULL;
/* free up transaction strings */
- g_cache_remove(gnc_engine_get_string_cache(), trans->num);
- g_cache_remove(gnc_engine_get_string_cache(), trans->description);
+ gnc_string_cache_remove(trans->num);
+ gnc_string_cache_remove(trans->description);
/* Just in case someone looks up freed memory ... */
trans->num = (char *) 1;
@@ -1718,13 +1718,13 @@
trans->common_currency = orig->common_currency;
- g_cache_remove (gnc_engine_get_string_cache(), trans->num);
+ gnc_string_cache_remove (trans->num);
trans->num = orig->num;
- orig->num = g_cache_insert(gnc_engine_get_string_cache(), "");
+ orig->num = gnc_string_cache_insert("");
- g_cache_remove (gnc_engine_get_string_cache(), trans->description);
+ gnc_string_cache_remove (trans->description);
trans->description = orig->description;
- orig->description = g_cache_insert(gnc_engine_get_string_cache(), "");
+ orig->description = gnc_string_cache_insert("");
kvp_frame_delete (trans->inst.kvp_data);
trans->inst.kvp_data = orig->inst.kvp_data;
@@ -1770,13 +1770,13 @@
break;
}
- g_cache_remove (gnc_engine_get_string_cache(), s->action);
+ gnc_string_cache_remove (s->action);
s->action = so->action;
- so->action = g_cache_insert(gnc_engine_get_string_cache(), "");
+ so->action = gnc_string_cache_insert("");
- g_cache_remove (gnc_engine_get_string_cache(), s->memo);
+ gnc_string_cache_remove (s->memo);
s->memo = so->memo;
- so->memo = g_cache_insert(gnc_engine_get_string_cache(), "");
+ so->memo = gnc_string_cache_insert("");
kvp_frame_delete (s->kvp_data);
s->kvp_data = so->kvp_data;
@@ -2502,8 +2502,8 @@
if (!trans || !xnum) return;
check_open (trans);
- tmp = g_cache_insert(gnc_engine_get_string_cache(), (gpointer) xnum);
- g_cache_remove(gnc_engine_get_string_cache(), trans->num);
+ tmp = gnc_string_cache_insert((gpointer) xnum);
+ gnc_string_cache_remove(trans->num);
trans->num = tmp;
}
@@ -2522,8 +2522,8 @@
if (!trans || !desc) return;
check_open (trans);
- tmp = g_cache_insert(gnc_engine_get_string_cache(), (gpointer) desc);
- g_cache_remove(gnc_engine_get_string_cache(), trans->description);
+ tmp = gnc_string_cache_insert((gpointer) desc);
+ gnc_string_cache_remove(trans->description);
trans->description = tmp;
}
@@ -2759,8 +2759,8 @@
if (!split || !memo) return;
check_open (split->parent);
- tmp = g_cache_insert(gnc_engine_get_string_cache(), (gpointer) memo);
- g_cache_remove(gnc_engine_get_string_cache(), split->memo);
+ tmp = gnc_string_cache_insert((gpointer) memo);
+ gnc_string_cache_remove(split->memo);
split->memo = tmp;
}
@@ -2781,8 +2781,8 @@
if (!split || !actn) return;
check_open (split->parent);
- tmp = g_cache_insert(gnc_engine_get_string_cache(), (gpointer) actn);
- g_cache_remove(gnc_engine_get_string_cache(), split->action);
+ tmp = gnc_string_cache_insert((gpointer) actn);
+ gnc_string_cache_remove(split->action);
split->action = tmp;
}
Index: gnc-pricedb.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/gnc-pricedb.c,v
retrieving revision 1.48.4.12
retrieving revision 1.48.4.13
diff -Lsrc/engine/gnc-pricedb.c -Lsrc/engine/gnc-pricedb.c -u -r1.48.4.12 -r1.48.4.13
--- src/engine/gnc-pricedb.c
+++ src/engine/gnc-pricedb.c
@@ -67,8 +67,8 @@
ENTER(" ");
gnc_engine_gen_event (&p->inst.entity, GNC_EVENT_DESTROY);
- if(p->type) g_cache_remove(gnc_engine_get_string_cache(), p->type);
- if(p->source) g_cache_remove(gnc_engine_get_string_cache(), p->source);
+ if(p->type) gnc_string_cache_remove(p->type);
+ if(p->source) gnc_string_cache_remove(p->source);
qof_instance_release (&p->inst);
memset(p, 0, sizeof(GNCPrice));
@@ -246,13 +246,11 @@
if(!p) return;
if(safe_strcmp(p->source, s) != 0)
{
- GCache *cache;
char *tmp;
gnc_price_begin_edit (p);
- cache = gnc_engine_get_string_cache();
- tmp = g_cache_insert(cache, (gpointer) s);
- if(p->source) g_cache_remove(cache, p->source);
+ tmp = gnc_string_cache_insert((gpointer) s);
+ if(p->source) gnc_string_cache_remove(p->source);
p->source = tmp;
if(p->db) p->db->inst.dirty = TRUE;
gnc_price_commit_edit (p);
@@ -265,13 +263,11 @@
if(!p) return;
if(safe_strcmp(p->type, type) != 0)
{
- GCache *cache;
gchar *tmp;
gnc_price_begin_edit (p);
- cache = gnc_engine_get_string_cache();
- tmp = g_cache_insert(cache, (gpointer) type);
- if(p->type) g_cache_remove(cache, p->type);
+ tmp = gnc_string_cache_insert((gpointer) type);
+ if(p->type) gnc_string_cache_remove(p->type);
p->type = tmp;
if(p->db) p->db->inst.dirty = TRUE;
gnc_price_commit_edit (p);
Index: gnc-engine.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/gnc-engine.c,v
retrieving revision 1.17.4.6
retrieving revision 1.17.4.7
diff -Lsrc/engine/gnc-engine.c -Lsrc/engine/gnc-engine.c -u -r1.17.4.6 -r1.17.4.7
--- src/engine/gnc-engine.c
+++ src/engine/gnc-engine.c
@@ -88,8 +88,6 @@
gnc_set_log_level(GNC_MOD_IO, GNC_LOG_WARNING);
gnc_set_log_level(GNC_MOD_GUI, GNC_LOG_WARNING);
qof_log_set_default(GNC_LOG_WARNING);
- /* initialize the string cache */
- gnc_engine_get_string_cache();
guid_init ();
qof_object_initialize ();
Index: gnc-commodity.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/gnc-commodity.c,v
retrieving revision 1.39.4.15
retrieving revision 1.39.4.16
diff -Lsrc/engine/gnc-commodity.c -Lsrc/engine/gnc-commodity.c -u -r1.39.4.15 -r1.39.4.16
--- src/engine/gnc-commodity.c
+++ src/engine/gnc-commodity.c
@@ -447,11 +447,14 @@
* gnc_commodity_new
********************************************************************/
+/* TODO: convert these to their more conventional form */
+#undef CACHE_INSERT
+#undef CACHE_REMOVE
#define CACHE_INSERT(dest,src) \
- if(src) { dest = g_cache_insert(str_cache, (gpointer)src); }
+ if(src) { dest = gnc_string_cache_insert((gpointer)src); }
#define CACHE_REMOVE(str) \
- if(str) { g_cache_remove(str_cache, str); str = NULL; }
+ if(str) { gnc_string_cache_remove(str); str=NULL; }
static void
mark_commodity_dirty (gnc_commodity *cm)
@@ -488,7 +491,6 @@
const char * exchange_code,
int fraction)
{
- GCache *str_cache = gnc_engine_get_string_cache ();
gnc_commodity * retval = g_new0(gnc_commodity, 1);
gnc_commodity_table *table;
@@ -526,7 +528,6 @@
void
gnc_commodity_destroy(gnc_commodity * cm)
{
- GCache *str_cache = gnc_engine_get_string_cache ();
if(!cm) return;
gnc_engine_gen_event (&cm->inst.entity, GNC_EVENT_DESTROY);
@@ -569,7 +570,6 @@
gnc_commodity *
gnc_commodity_clone(gnc_commodity *src)
{
- GCache *str_cache = gnc_engine_get_string_cache ();
gnc_commodity * dest = g_new0(gnc_commodity, 1);
CACHE_INSERT (dest->fullname, src->fullname);
@@ -739,7 +739,6 @@
void
gnc_commodity_set_mnemonic(gnc_commodity * cm, const char * mnemonic)
{
- GCache *str_cache = gnc_engine_get_string_cache ();
if(!cm) return;
if(cm->mnemonic == mnemonic) return;
@@ -782,7 +781,6 @@
void
gnc_commodity_set_fullname(gnc_commodity * cm, const char * fullname)
{
- GCache *str_cache = gnc_engine_get_string_cache ();
if(!cm) return;
if(cm->fullname == fullname) return;
@@ -801,7 +799,6 @@
gnc_commodity_set_exchange_code(gnc_commodity * cm,
const char * exchange_code)
{
- GCache *str_cache = gnc_engine_get_string_cache ();
if(!cm) return;
if(cm->exchange_code == exchange_code) return;
@@ -870,7 +867,6 @@
void
gnc_commodity_set_quote_tz(gnc_commodity *cm, const char *tz)
{
- GCache *str_cache = gnc_engine_get_string_cache ();
ENTER ("(cm=%p, tz=%s)", cm, tz);
if(!cm) return;
@@ -1173,7 +1169,6 @@
gnc_commodity_table_insert(gnc_commodity_table * table,
gnc_commodity * comm)
{
- GCache *str_cache;
gnc_commodity_namespace * nsp = NULL;
gnc_commodity *c;
const char *ns_name;
@@ -1197,11 +1192,11 @@
}
nsp = gnc_commodity_table_add_namespace(table, ns_name);
- str_cache = gnc_engine_get_string_cache ();
- PINFO ("insert %p %s into nsp=%p %s", comm->mnemonic, comm->mnemonic, nsp->cm_table, nsp->name);
+ PINFO ("insert %p %s into nsp=%p %s", comm->mnemonic, comm->mnemonic,
+ nsp->cm_table, nsp->name);
g_hash_table_insert(nsp->cm_table,
- (gpointer)g_cache_insert(str_cache, comm->mnemonic),
+ gnc_string_cache_insert(comm->mnemonic),
(gpointer)comm);
nsp->cm_list = g_list_append(nsp->cm_list, comm);
@@ -1432,10 +1427,9 @@
ns = gnc_commodity_table_find_namespace(table, namespace);
if(!ns)
{
- GCache *str_cache = gnc_engine_get_string_cache ();
ns = g_new0(gnc_commodity_namespace, 1);
ns->cm_table = g_hash_table_new(g_str_hash, g_str_equal);
- ns->name = g_cache_insert(str_cache, (gpointer)namespace);
+ ns->name = gnc_string_cache_insert((gpointer)namespace);
gnc_engine_gen_event (&ns->inst.entity, GNC_EVENT_CREATE);
g_hash_table_insert(table->ns_table,
@@ -1487,10 +1481,9 @@
static int
ns_helper(gpointer key, gpointer value, gpointer user_data)
{
- GCache *str_cache = user_data;
gnc_commodity * c = value;
gnc_commodity_destroy(c);
- g_cache_remove (str_cache, key); /* key is commodity mnemonic */
+ gnc_string_cache_remove(key); /* key is commodity mnemonic */
return TRUE;
}
@@ -1499,7 +1492,6 @@
const char * namespace)
{
gnc_commodity_namespace * ns;
- GCache *str_cache;
if (!table) return;
@@ -1514,10 +1506,9 @@
g_list_free(ns->cm_list);
ns->cm_list = NULL;
- str_cache = gnc_engine_get_string_cache ();
- g_hash_table_foreach_remove(ns->cm_table, ns_helper, str_cache);
+ g_hash_table_foreach_remove(ns->cm_table, ns_helper, NULL);
g_hash_table_destroy(ns->cm_table);
- g_cache_remove (str_cache, ns->name);
+ gnc_string_cache_remove(ns->name);
gnc_engine_gen_event (&ns->inst.entity, GNC_EVENT_DESTROY);
g_free(ns);
Index: test-commodities.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/test/test-commodities.c,v
retrieving revision 1.7.4.5
retrieving revision 1.7.4.6
diff -Lsrc/engine/test/test-commodities.c -Lsrc/engine/test/test-commodities.c -u -r1.7.4.5 -r1.7.4.6
--- src/engine/test/test-commodities.c
+++ src/engine/test/test-commodities.c
@@ -179,17 +179,15 @@
int
main (int argc, char **argv)
{
- gnc_engine_get_string_cache ();
- guid_init ();
- qof_object_initialize ();
- qof_query_init ();
- qof_book_register ();
- gnc_commodity_table_register();
- test_commodity();
- print_test_results();
- qof_query_shutdown();
- guid_shutdown();
- qof_object_shutdown ();
- gnc_engine_string_cache_destroy();
- return 0;
+ guid_init ();
+ qof_object_initialize ();
+ qof_query_init ();
+ qof_book_register ();
+ gnc_commodity_table_register();
+ test_commodity();
+ print_test_results();
+ qof_query_shutdown();
+ guid_shutdown();
+ qof_object_shutdown ();
+ return 0;
}
Index: gnc-component-manager.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/app-utils/gnc-component-manager.c,v
retrieving revision 1.13.4.5
retrieving revision 1.13.4.6
diff -Lsrc/app-utils/gnc-component-manager.c -Lsrc/app-utils/gnc-component-manager.c -u -r1.13.4.5 -r1.13.4.6
--- src/app-utils/gnc-component-manager.c
+++ src/app-utils/gnc-component-manager.c
@@ -64,6 +64,7 @@
/** Static Variables ************************************************/
static guint suspend_counter = 0;
+/* Some code foolishly uses 0 instead of NO_COMPONENT, so we start with 1. */
static gint next_component_id = 1;
static GList *components = NULL;
@@ -127,9 +128,7 @@
static gboolean
destroy_mask_hash_helper (gpointer key, gpointer value, gpointer user_data)
{
- GCache *gc = gnc_engine_get_string_cache ();
-
- g_cache_remove (gc, key);
+ gnc_string_cache_remove (key);
g_free (value);
return TRUE;
@@ -246,8 +245,7 @@
mask = g_hash_table_lookup (cei->event_masks, entity_type);
if (!mask)
{
- char * key = g_cache_insert (gnc_engine_get_string_cache (),
- (gpointer) entity_type);
+ char * key = gnc_string_cache_insert ((gpointer) entity_type);
mask = g_new0 (GNCEngineEventType, 1);
g_hash_table_insert (cei->event_masks, key, mask);
}
Index: test-employee.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/test/test-employee.c,v
retrieving revision 1.6.4.5
retrieving revision 1.6.4.6
diff -Lsrc/business/business-core/test/test-employee.c -Lsrc/business/business-core/test/test-employee.c -u -r1.6.4.5 -r1.6.4.6
--- src/business/business-core/test/test-employee.c
+++ src/business/business-core/test/test-employee.c
@@ -217,7 +217,6 @@
int
main (int argc, char **argv)
{
- gnc_engine_get_string_cache ();
guid_init ();
qof_query_init ();
qof_object_initialize ();
@@ -225,12 +224,11 @@
do_test (gncInvoiceRegister(), "Cannot register GncInvoice");
do_test (gncJobRegister (), "Cannot register GncJob");
do_test (gncCustomerRegister(), "Cannot register GncCustomer");
- do_test (gncEmployeeRegister(), "Cannot register GncEmployee");
+ do_test (gncEmployeeRegister(), "Cannot register GncEmployee");
test_employee();
print_test_results();
qof_query_shutdown();
guid_shutdown();
qof_object_shutdown ();
- gnc_engine_string_cache_destroy();
return 0;
}
Index: test-job.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/test/test-job.c,v
retrieving revision 1.8.4.5
retrieving revision 1.8.4.6
diff -Lsrc/business/business-core/test/test-job.c -Lsrc/business/business-core/test/test-job.c -u -r1.8.4.5 -r1.8.4.6
--- src/business/business-core/test/test-job.c
+++ src/business/business-core/test/test-job.c
@@ -234,7 +234,6 @@
int
main (int argc, char **argv)
{
- gnc_engine_get_string_cache ();
guid_init ();
qof_query_init ();
qof_object_initialize ();
@@ -247,7 +246,6 @@
qof_query_shutdown();
guid_shutdown();
qof_object_shutdown ();
- gnc_engine_string_cache_destroy();
return 0;
}
Index: test-customer.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/test/test-customer.c,v
retrieving revision 1.9.4.4
retrieving revision 1.9.4.5
diff -Lsrc/business/business-core/test/test-customer.c -Lsrc/business/business-core/test/test-customer.c -u -r1.9.4.4 -r1.9.4.5
--- src/business/business-core/test/test-customer.c
+++ src/business/business-core/test/test-customer.c
@@ -205,17 +205,15 @@
int
main (int argc, char **argv)
{
- gnc_engine_get_string_cache ();
guid_init ();
- qof_query_init ();
+ qof_query_init ();
qof_object_initialize ();
qof_book_register ();
- do_test (cashobjects_register(), "Cannot register cash objects");
+ do_test (cashobjects_register(), "Cannot register cash objects");
test_customer();
print_test_results();
- qof_query_shutdown();
+ qof_query_shutdown();
guid_shutdown();
- qof_object_shutdown ();
- gnc_engine_string_cache_destroy();
+ qof_object_shutdown ();
return 0;
}
Index: test-vendor.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/test/test-vendor.c,v
retrieving revision 1.10.4.5
retrieving revision 1.10.4.6
diff -Lsrc/business/business-core/test/test-vendor.c -Lsrc/business/business-core/test/test-vendor.c -u -r1.10.4.5 -r1.10.4.6
--- src/business/business-core/test/test-vendor.c
+++ src/business/business-core/test/test-vendor.c
@@ -215,7 +215,6 @@
int
main (int argc, char **argv)
{
- gnc_engine_get_string_cache ();
guid_init ();
qof_query_init ();
qof_object_initialize ();
@@ -229,6 +228,5 @@
qof_query_shutdown();
guid_shutdown();
qof_object_shutdown ();
- gnc_engine_string_cache_destroy();
return 0;
}
Index: QuickFill.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/QuickFill.c,v
retrieving revision 1.1.4.5
retrieving revision 1.1.4.6
diff -Lsrc/gnome-utils/QuickFill.c -Lsrc/gnome-utils/QuickFill.c -u -r1.1.4.5 -r1.1.4.6
--- src/gnome-utils/QuickFill.c
+++ src/gnome-utils/QuickFill.c
@@ -49,10 +49,6 @@
/* This static indicates the debugging module that this .o belongs to. */
static QofLogModule log_module = GNC_MOD_REGISTER;
-/* A cache for quickfill strings */
-static GCache * qf_string_cache = NULL;
-
-
/********************************************************************\
\********************************************************************/
@@ -85,10 +81,6 @@
return NULL;
}
- /* For now, use the engine cache. */
- if (qf_string_cache == NULL)
- qf_string_cache = gnc_engine_get_string_cache ();
-
qf = g_new (QuickFill, 1);
qf->text = NULL;
@@ -120,7 +112,7 @@
qf->matches = NULL;
if (qf->text)
- g_cache_remove (qf_string_cache, qf->text);
+ gnc_string_cache_remove(qf->text);
qf->text = NULL;
qf->len = 0;
@@ -136,7 +128,7 @@
g_hash_table_foreach_remove (qf->matches, destroy_helper, NULL);
if (qf->text)
- g_cache_remove (qf_string_cache, qf->text);
+ gnc_string_cache_remove (qf->text);
qf->text = NULL;
qf->len = 0;
}
@@ -318,7 +310,7 @@
/* If there's no string there already, just put the new one in. */
if (old_text == NULL)
{
- match_qf->text = g_cache_insert (qf_string_cache, (gpointer) text);
+ match_qf->text = gnc_string_cache_insert((gpointer) text);
match_qf->len = len;
break;
}
@@ -328,8 +320,8 @@
(strncmp(text, old_text, strlen(old_text)) == 0))
break;
- g_cache_remove (qf_string_cache, old_text);
- match_qf->text = g_cache_insert (qf_string_cache, (gpointer) text);
+ gnc_string_cache_remove(old_text);
+ match_qf->text = gnc_string_cache_insert((gpointer) text);
match_qf->len = len;
break;
}
More information about the gnucash-changes
mailing list