i'm trying to use a binary that has a main node, and every leaf is also a node that has leaves.
So i'm using a struct that's called node and this node has two nodes in it.
i defined a struct like

typedef struct element{
    int IP;
    int counter;

typedef struct node {
    ELEMENT node_element;
    struct node *left;
    struct node *right;

(i attached my code to the mail)

i want to add a new node into tree and i use shared memory to hold the entire tree. If the IP of new node is smaller, i put it to he left leaf. If IP of new node is greater, i put it into the right leaf. The right and left leaves are also nodes and they have right and left leaves.

Anyway, my point is when i want to insert new nodes, i'm using the apr_shm_baseaddr_get function to get the address and try to insert ner node into it. But when i add another node as a leaf, it also changes the root node.

the examle output of the attached code is like this (i'm printing the root node and the right leaf node)
they are same.
what i'm expecting is

Do you have any advices?

Oğuzhan TOPGÜL