r18612 - gnucash/trunk/src - Corrections to r18610 to permit compiling against older versions of glib

Derek Atkins warlord at MIT.EDU
Mon Feb 8 12:34:07 EST 2010


Hi,

John Ralls <jralls at code.gnucash.org> writes:

> -    gnc_numeric *key;
> +    gnc_numeric *key = NULL;
> +	gpointer pkey = (gpointer)key; 
>      GList *reachable_list = 0, *node;
>  
>      printf("  Split value: %s\n", gnc_numeric_to_string(split_value));
>  
>      /* For each value in the sack */
>      g_hash_table_iter_init (&iter, sack);
> -    while (g_hash_table_iter_next (&iter, (gpointer *)&key, NULL))
> +    while (g_hash_table_iter_next (&iter, &pkey, NULL))
>      {
>        /* Compute a new reachable value */
>        gnc_numeric reachable_value = gnc_numeric_add_fixed(*key, split_value);

I don't think this is going to work right..  the g_hash_table_iter_next()
will set pkey, but that wont change the value of key.  So the
gnc_numeric_add_fixed() will fail because *key will still be NULL.

What was wrong with the original code?

> @@ -203,10 +204,11 @@
>    printf("Rebuilding solution ...\n");
>    while (!gnc_numeric_zero_p(toclear_value))
>    {
> -    Split *split;
> +    Split *split = NULL;
> +	gpointer psplit = (gpointer)split;
>  
>      printf("  Left to clear: %s\n", gnc_numeric_to_string(toclear_value));
> -    if (g_hash_table_lookup_extended(sack, &toclear_value, NULL, (gpointer *)&split))
> +    if (g_hash_table_lookup_extended(sack, &toclear_value, NULL, &psplit))
>      {
>        if (split != NULL)

Same problem here!   psplit will get set, but that wont affect the value
of split.  The original code looks just fine to me!

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the gnucash-devel mailing list