server/modules/selva/module/edge.c
static struct EdgeField *Edge_NewField(
        struct SelvaModify_HierarchyNode *node,
        const char *field_name_str,
        size_t field_name_len,
        const struct EdgeFieldConstraint *constraint) {
    Selva_NodeId node_id;
    struct SelvaModify_HierarchyMetadata *node_metadata;
    struct SelvaObject *edges;
    struct EdgeField *edge_field;

    SelvaHierarchy_GetNodeId(node_id, node);
    node_metadata = SelvaHierarchy_GetNodeMetadataByPtr(node);

    edges = node_metadata->edge_fields.edges;
    if (!edges) {
        edges = SelvaObject_New();
        if (!edges) {
            return NULL;
        }

        node_metadata->edge_fields.edges = edges;
    }

    edge_field = alloc_EdgeField(node_id, constraint, 0);
    if (!edge_field) {
        /* Just leave the edges obj there as it's already properly initialized. */
        return NULL;
    }

    SelvaObject_SetPointerStr(edges, field_name_str, field_name_len, edge_field, &obj_opts);

    return edge_field;
}
/**
 * Create a new edge field and store it on the hierarchy node.
 */
Create a new edge field and store it on the hierarchy node.
Create a new edge field and store it on the hierarchy node .
static struct EdgeField *Edge_NewField(
        struct SelvaModify_HierarchyNode *node,
        const char *field_name_str,
        size_t field_name_len,
        const struct EdgeFieldConstraint *constraint) {
    Selva_NodeId node_id;
    struct SelvaModify_HierarchyMetadata *node_metadata;
    struct SelvaObject *edges;
    struct EdgeField *edge_field;
    SelvaHierarchy_GetNodeId(node_id, node);
    node_metadata = SelvaHierarchy_GetNodeMetadataByPtr(node);
    edges = node_metadata->edge_fields.edges;
    if (!edges) {
        edges = SelvaObject_New();
        if (!edges) {
            return NULL;
        }
        node_metadata->edge_fields.edges = edges;
    }
    edge_field = alloc_EdgeField(node_id, constraint, 0);
    if (!edge_field) {
        return NULL;
    }
    SelvaObject_SetPointerStr(edges, field_name_str, field_name_len, edge_field, &obj_opts);
    return edge_field;
}
static struct EdgeField * Edge_NewField ( struct SelvaModify_HierarchyNode * node , const char * field_name_str , size_t field_name_len , const struct EdgeFieldConstraint * constraint ) { Selva_NodeId node_id ; struct SelvaModify_HierarchyMetadata * node_metadata ; struct SelvaObject * edges ; struct EdgeField * edge_field ; SelvaHierarchy_GetNodeId ( node_id , node ) ; node_metadata = SelvaHierarchy_GetNodeMetadataByPtr ( node ) ; edges = node_metadata -> edge_fields . edges ; if ( ! edges ) { edges = SelvaObject_New ( ) ; if ( ! edges ) { return NULL ; } node_metadata -> edge_fields . edges = edges ; } edge_field = alloc_EdgeField ( node_id , constraint , 0 ) ; if ( ! edge_field ) { return NULL ; } SelvaObject_SetPointerStr ( edges , field_name_str , field_name_len , edge_field , & obj_opts ) ; return edge_field ; }
Create a new edge field and store it on the hierarchy node.
Create a new edge field and store it on the hierarchy node .
/* Just leave the edges obj there as it's already properly initialized. */