server/modules/selva/module/edge.c
static void insert_edge(struct EdgeField *src_edge_field, struct SelvaModify_HierarchyNode *dst_node) {
    struct SelvaModify_HierarchyMetadata *dst_node_metadata;
    int err;

    /*
     *  Insert the hierarchy node to the edge field.
     */
    SVector_InsertFast(&src_edge_field->arcs, dst_node);

    /*
     * Add origin reference.
     * Note that we must ensure that this insertion is only ever done once.
     */
    dst_node_metadata = SelvaHierarchy_GetNodeMetadataByPtr(dst_node);

    /* TODO can we avoid crashing in the following error cases? */
    if (!dst_node_metadata->edge_fields.origins) {
        /* The edge origin refs struct is initialized lazily. */
        dst_node_metadata->edge_fields.origins = SelvaObject_New();
        if (!dst_node_metadata->edge_fields.origins) {
            fprintf(stderr, "%s:%d: OOM while inserting an edge\n",
                    __FILE__, __LINE__);
            abort();
        }
    }
    err = SelvaObject_AddArrayStr(dst_node_metadata->edge_fields.origins,
                                  src_edge_field->src_node_id, SELVA_NODE_ID_SIZE,
                                  SELVA_OBJECT_POINTER, src_edge_field);
    if (err) {
        fprintf(stderr, "%s:%d: Edge origin update failed: %s\n",
                __FILE__, __LINE__,
                getSelvaErrorStr(err));
        abort();
    }
}
/**
 * Insert an edge.
 * The edge must not exist before calling this function because this
 * function doesn't perform any checks.
 */
Insert an edge.
The edge must not exist before calling this function because this
function doesn't perform any checks.
Insert an edge . The edge must not exist before calling this function because this function doesn ' t perform any checks .
static void insert_edge(struct EdgeField *src_edge_field, struct SelvaModify_HierarchyNode *dst_node) {
    struct SelvaModify_HierarchyMetadata *dst_node_metadata;
    int err;
    SVector_InsertFast(&src_edge_field->arcs, dst_node);
    dst_node_metadata = SelvaHierarchy_GetNodeMetadataByPtr(dst_node);
    if (!dst_node_metadata->edge_fields.origins) {
        dst_node_metadata->edge_fields.origins = SelvaObject_New();
        if (!dst_node_metadata->edge_fields.origins) {
            fprintf(stderr, "%s:%d: OOM while inserting an edge\n",
                    __FILE__, __LINE__);
            abort();
        }
    }
    err = SelvaObject_AddArrayStr(dst_node_metadata->edge_fields.origins,
                                  src_edge_field->src_node_id, SELVA_NODE_ID_SIZE,
                                  SELVA_OBJECT_POINTER, src_edge_field);
    if (err) {
        fprintf(stderr, "%s:%d: Edge origin update failed: %s\n",
                __FILE__, __LINE__,
                getSelvaErrorStr(err));
        abort();
    }
}
static void insert_edge ( struct EdgeField * src_edge_field , struct SelvaModify_HierarchyNode * dst_node ) { struct SelvaModify_HierarchyMetadata * dst_node_metadata ; int err ; SVector_InsertFast ( & src_edge_field -> arcs , dst_node ) ; dst_node_metadata = SelvaHierarchy_GetNodeMetadataByPtr ( dst_node ) ; if ( ! dst_node_metadata -> edge_fields . origins ) { dst_node_metadata -> edge_fields . origins = SelvaObject_New ( ) ; if ( ! dst_node_metadata -> edge_fields . origins ) { fprintf ( stderr , " \n " , __FILE__ , __LINE__ ) ; abort ( ) ; } } err = SelvaObject_AddArrayStr ( dst_node_metadata -> edge_fields . origins , src_edge_field -> src_node_id , SELVA_NODE_ID_SIZE , SELVA_OBJECT_POINTER , src_edge_field ) ; if ( err ) { fprintf ( stderr , " \n " , __FILE__ , __LINE__ , getSelvaErrorStr ( err ) ) ; abort ( ) ; } }
Insert an edge.
Insert an edge .
/*
     *  Insert the hierarchy node to the edge field.
     */ /*
     * Add origin reference.
     * Note that we must ensure that this insertion is only ever done once.
     */ /* TODO can we avoid crashing in the following error cases? */ /* The edge origin refs struct is initialized lazily. */