Dear Jordan, Thanks for quick answer. I am not very good in extensive pointer programming. So it will be very nice of you if you can clarify some more things.
1. Is the following function ok? GArray* g_array_clone(GArray *array) { int i; GArray *clone = g_array_new(FALSE,FALSE,sizeof(long)); for(i=0;i<array->len;i++) g_array_append_val(clone,(long)g_array_index(array,long,i)); return clone; } 2. I want reconstruct a tree from a text file. For that I need to iteratively read node information (node names as a string) from the file and add the node to the tree. In this case how can I add the string to the ->data? Thanks in advance, Kaustubh --- Jordan Walsh <[EMAIL PROTECTED]> wrote: > On Thu, 2008-03-27 at 10:01 -0700, Kaustubh Patil > wrote: > > Hi, > > > > I am using glib (version 2.0) for developing some > > applications. I have some questions about use of > > Garray and GNode (G-n-ary tree). > > > > 1. Is it safe to return an initialized GArray * > from a > > function? e.g. copying garray array1 into garray > > array2 and then returning pointer to array2. > > > > 2. For n-ary tree, is it possible to add strings > > (static) as data? > > > > 3. Is it possible to add a structure as data in > > n-ary-tree? If yes, how to the functions like > > g_node_find work? > > > > Thanks in advance, > > Kaustubh > > > > > > > > > ____________________________________________________________________________________ > > Be a better friend, newshound, and > > know-it-all with Yahoo! Mobile. Try it now. > http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ > > _______________________________________________ > > gtk-app-devel-list mailing list > > gtk-app-devel-list@gnome.org > > > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > > 1. Yes, just keep in mind to free any temporary > data, and that garray2 > will have to be freed by whatever needs the copy. > > 2. You can add anything as data (answers 3 also) > data is just a pointer > to the "actual data". to clarify.. no you cannot add > an "int". but you > can add a pointer to an int* or &int, string, GList, > etc. > > 3. yes.. just add a pointer to your structure as > ->data and typecast > where needed. > > > ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list