Re: [gnome-db] GdaDataModelHash error.... patch attached



On Nov 30, 2007 7:40 AM, Sumit Kumar Jain <sumitskj_20 yahoo com> wrote:
>
> Hi,
> I think i found a bug in GdaDataModelHash. The libgda version that i am
> using is 3.0. The following gives error. However after patching with the
> attahced file, the error goes away.
>
> ---------------- code snippet ------------------
> #include <stdio.h>
> #include <libgda/libgda.h>
> #define NOERROR 0
> #define ERROR 1
>
> int main()
> {
>         int retVal = NOERROR;
>
>         gda_init ("TestGDA", NULL, 0, NULL);
>
>         GdaDataModelHash *hash_model = (GdaDataModelHash
> *)gda_data_model_hash_new(2);
>
>         if(!hash_model)
>         {
>                 retVal = ERROR;
>         }
>
>         GValue *value = NULL;
>     GList *list = NULL;
>
>     g_value_set_int(value = gda_value_new(G_TYPE_INT),10);
>     list = g_list_append(list,value);
>
>     g_value_set_string(value = gda_value_new(G_TYPE_STRING),"test");
>     list = g_list_append(list,value);
>
>     gda_data_model_append_values(GDA_DATA_MODEL(hash_model),list,NULL);
>
>     g_list_foreach(list,(GFunc)gda_value_free,NULL);
>     g_list_free(list);
>
>     list = NULL;
>
> g_value_set_int(value = gda_value_new(G_TYPE_INT),11);
>     list = g_list_append(list,value);
>
>     g_value_set_string(value = gda_value_new(G_TYPE_STRING),"test1");
>     list = g_list_append(list,value);
>
>     gda_data_model_append_values(GDA_DATA_MODEL(hash_model),list,NULL);
>
>     g_list_foreach(list,(GFunc)gda_value_free,NULL);
>     g_list_free(list);
>
>     const GValue *val1 =
> gda_data_model_get_value_at(GDA_DATA_MODEL(hash_model),0,0);
>
>     if(!val1)
>     {
>         retVal = ERROR;
>     }
>
>     int no = g_value_get_int(val1);
>
>     if(no != 10)
>     {
>         retVal = ERROR;
>     }
>
> end:
>
>         g_object_unref(G_OBJECT(hash_model));
>         return retVal;
> }
>
>
> ---------------- End code snippet ------------------
>
>
>
> Regards,
>
> Sumit

Thanks for the patch, I will commit that tonight if I get the time.

Cheers,

Vivien


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]