mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Fix GCC pointer strictness compiler errors/warnings and remove duplicate code
Patch by Matt Lavin <matt.lavin@gmail.com> (with const added by myself). git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18401 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
c2111f45f5
commit
eac59d32d1
@ -713,7 +713,8 @@ guid_hash_to_guint (gconstpointer ptr)
|
|||||||
|
|
||||||
if (sizeof(guint) <= sizeof(guid->data))
|
if (sizeof(guint) <= sizeof(guid->data))
|
||||||
{
|
{
|
||||||
return (*((guint *) guid->data));
|
const guint* ptr_data = (const guint *) guid->data;
|
||||||
|
return (*ptr_data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -58,48 +58,13 @@ qof_set_alt_dirty_mode (gboolean enabled)
|
|||||||
|
|
||||||
/* =============================================================== */
|
/* =============================================================== */
|
||||||
|
|
||||||
static guint
|
|
||||||
id_hash (gconstpointer key)
|
|
||||||
{
|
|
||||||
const GUID *guid = key;
|
|
||||||
|
|
||||||
if (key == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Compiler should optimize this all away! */
|
|
||||||
if (sizeof(guint) <= 16)
|
|
||||||
return *((guint *) guid->data);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
guint hash = 0;
|
|
||||||
unsigned int i, j;
|
|
||||||
|
|
||||||
for (i = 0, j = 0; i < sizeof(guint); i++, j++)
|
|
||||||
{
|
|
||||||
if (j == 16)
|
|
||||||
j = 0;
|
|
||||||
|
|
||||||
hash <<= 4;
|
|
||||||
hash |= guid->data[j];
|
|
||||||
}
|
|
||||||
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
id_compare(gconstpointer key_1, gconstpointer key_2)
|
|
||||||
{
|
|
||||||
return guid_equal (key_1, key_2);
|
|
||||||
}
|
|
||||||
|
|
||||||
QofCollection *
|
QofCollection *
|
||||||
qof_collection_new (QofIdType type)
|
qof_collection_new (QofIdType type)
|
||||||
{
|
{
|
||||||
QofCollection *col;
|
QofCollection *col;
|
||||||
col = g_new0(QofCollection, 1);
|
col = g_new0(QofCollection, 1);
|
||||||
col->e_type = CACHE_INSERT (type);
|
col->e_type = CACHE_INSERT (type);
|
||||||
col->hash_of_entities = g_hash_table_new (id_hash, id_compare);
|
col->hash_of_entities = guid_hash_table_new();
|
||||||
col->data = NULL;
|
col->data = NULL;
|
||||||
return col;
|
return col;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user