cleanup grungy utils, I need to be able to use this

in a different, unrelated app.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@8418 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 2003-05-28 23:27:05 +00:00
parent 7b50af16ff
commit 2c68f3b4b3
6 changed files with 36 additions and 61 deletions

View File

@ -83,6 +83,7 @@ gncinclude_HEADERS = \
gncObject.h \
kvp_frame.h \
kvp-scm.h \
kvp-util.h \
messages.h
noinst_HEADERS = \

View File

@ -424,37 +424,6 @@ gnc_stpcpy (char *dest, const char *src)
return (dest + strlen (src));
}
/********************************************************************\
See header for docs.
\********************************************************************/
static void
kv_pair_helper(gpointer key, gpointer val, gpointer user_data)
{
GSList **result = (GSList **) user_data;
GHashTableKVPair *kvp = g_new(GHashTableKVPair, 1);
kvp->key = key;
kvp->value = val;
*result = g_slist_prepend(*result, kvp);
}
GSList *
g_hash_table_key_value_pairs(GHashTable *table)
{
GSList *result_list = NULL;
g_hash_table_foreach(table, kv_pair_helper, &result_list);
return result_list;
}
void
g_hash_table_kv_pair_free_gfunc(gpointer data, gpointer user_data)
{
GHashTableKVPair *kvp = (GHashTableKVPair *) data;
g_free(kvp);
}
/********************************************************************\
Callbacks so that the engine can display gui messages.
\********************************************************************/

View File

@ -37,9 +37,6 @@
#include "config.h"
#include "gnc-commodity.h"
#include "gnc-numeric.h"
/** DEBUGGING MACROS ************************************************/
/* The debuging macros enable the setting of trace messages */
@ -280,29 +277,5 @@ char * gnc_stpcpy (char *dest, const char *src);
#define stpcpy gnc_stpcpy
#endif
/***********************************************************************\
g_hash_table_key_value_pairs(hash): Returns a GSList* of all the
keys and values in a given hash table. Data elements of lists are
actual hash elements, so be careful, and deallocation of the
GHashTableKVPairs in the result list are the caller's
responsibility. A typical sequence might look like this:
GSList *kvps = g_hash_table_key_value_pairs(hash);
... use kvps->data->key and kvps->data->val, etc. here ...
g_slist_foreach(kvps, g_hash_table_kv_pair_free_gfunc, NULL);
g_slist_free(kvps);
*/
typedef struct {
gpointer key;
gpointer value;
} GHashTableKVPair;
GSList *g_hash_table_key_value_pairs(GHashTable *table);
void g_hash_table_kv_pair_free_gfunc(gpointer data, gpointer user_data);
/***********************************************************************/
#endif

View File

@ -35,6 +35,7 @@
#include "gnc-event-p.h"
#include "gnc-pricedb-p.h"
#include "guid.h"
#include "kvp-util.h"
/* This static indicates the debugging module that this .o belongs to. */
static short module = MOD_PRICE;

View File

@ -28,6 +28,7 @@
#include "gnc-engine-util.h"
#include "kvp_frame.h"
#include "kvp-util.h"
#include "kvp-util-p.h"
/* ================================================================ */
@ -88,4 +89,34 @@ gnc_kvp_gemini (kvp_frame *kvp_root, const GUID *acct_guid,
}
/* ================================================================ */
/*
* See header for docs.
*/
static void
kv_pair_helper(gpointer key, gpointer val, gpointer user_data)
{
GSList **result = (GSList **) user_data;
GHashTableKVPair *kvp = g_new(GHashTableKVPair, 1);
kvp->key = key;
kvp->value = val;
*result = g_slist_prepend(*result, kvp);
}
GSList *
g_hash_table_key_value_pairs(GHashTable *table)
{
GSList *result_list = NULL;
g_hash_table_foreach(table, kv_pair_helper, &result_list);
return result_list;
}
void
g_hash_table_kv_pair_free_gfunc(gpointer data, gpointer user_data)
{
GHashTableKVPair *kvp = (GHashTableKVPair *) data;
g_free(kvp);
}
/*======================== END OF FILE =============================*/

View File

@ -22,8 +22,8 @@
/** @file kvp-util.h @brief GnuCash KVP utility functions */
#ifndef GNC_ENGINE_UTIL_H
#define GNC_ENGINE_UTIL_H
#ifndef GNC_KVP_UTIL_H
#define GNC_KVP_UTIL_H
#include "config.h"
@ -52,4 +52,4 @@ void g_hash_table_kv_pair_free_gfunc(gpointer data, gpointer user_data);
/***********************************************************************/
#endif
#endif /* GNC_KVP_UTIL_H */