Re: GNode question



vladimir wrote:

Good day,
Developers!

This is my question:

        I have a GNode tree set up like this:

                        +----------------+
                        | main_node NULL |
             +---------+-------+--------+--------+
             |                 |                 |
       +-----+-----+     +-----+-----+     +-----+-----+
       | node1 NULL|     | node2 NULL|     | node3 NULL|
       +-----------+     +-----------+     +-----------+

        They are all set up with >> g_node_new (NULL) << so, they do not
contain any data. Now, can i just assign some data to child node?
        
        Something like (for node2):

        node = g_node_nth_child (main_node, 1);
        node->data = g_strdup ("Some char* data"); ?

        Of course, I will free nodes when not needed anymore. Is this OK, or
should I do it another way?

Hello, Vladimir
You can do with GNode *data* field anything you want.

Olexiy





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