third_party/inchi/INCHI_BASE/src/runichi3.c
void OAD_CollectBackboneAtoms(ORIG_ATOM_DATA  *at_data,
                              int na,
                              int *alist,
                              int end_atom1,
                              int end_atom2,
                              int *nbkatoms,
                              int *bkatoms,
                              int *err,
                              char *pStrErr)
{
    int start = 0, end = 0;
    subgraf *sg = NULL;
    subgraf_pathfinder *spf = NULL;
    int nbkbonds=0;
    int **bkbonds=NULL;		/* list of [breakable] backbone bonds	[ (a1,a2), (a3,a4), ... ]	*/
    int maxbkbonds;

    *nbkatoms = 0;
    maxbkbonds = at_data->num_inp_bonds + 2;
    *err = imat_new(maxbkbonds, 2, &(bkbonds));
    if (*err)
    {
        TREAT_ERR(*err, 9034, "Not enough memory (polymers)");
        goto exit_function;
    }
    nbkbonds = 0;
    sg = subgraf_new(at_data, na, alist);
    if (!sg)
    {
        TREAT_ERR(*err, 9037, "Not enough memory (polymers)");
        goto exit_function;
    }

    start = sg->orig2node[end_atom1]; end = sg->orig2node[end_atom2];
    if (start > end)
    {
        int tmp = end;
        end = start;
        start = tmp;
    }
    spf = subgraf_pathfinder_new(sg, at_data, start, end);
    if (!spf)
    {
        TREAT_ERR(*err, 9039, "Not enough memory (polymers)");
        goto exit_function;
    }

    spf->seen[0] = spf->start; spf->nseen = 1;    
    nbkbonds = 0;
    *nbkatoms = 0;
    
    subgraf_pathfinder_run(spf, 0, NULL, &nbkbonds, bkbonds, nbkatoms, bkatoms);

    subgraf_free(sg);
    subgraf_pathfinder_free(spf);
    *err = 0;


exit_function:
    if (bkbonds)
    {
        imat_free(maxbkbonds, bkbonds);
        bkbonds = NULL;
    }	

    return;
}
/****************************************************************************
Collect all backbone atoms - of main chain(s), side chains being ignored
****************************************************************************/
Collect all backbone atoms - of main chain(s), side chains being ignored
Collect all backbone atoms - of main chain ( s ) side chains being ignored
void OAD_CollectBackboneAtoms(ORIG_ATOM_DATA  *at_data,
                              int na,
                              int *alist,
                              int end_atom1,
                              int end_atom2,
                              int *nbkatoms,
                              int *bkatoms,
                              int *err,
                              char *pStrErr)
{
    int start = 0, end = 0;
    subgraf *sg = NULL;
    subgraf_pathfinder *spf = NULL;
    int nbkbonds=0;
    int **bkbonds=NULL;		
    int maxbkbonds;
    *nbkatoms = 0;
    maxbkbonds = at_data->num_inp_bonds + 2;
    *err = imat_new(maxbkbonds, 2, &(bkbonds));
    if (*err)
    {
        TREAT_ERR(*err, 9034, "Not enough memory (polymers)");
        goto exit_function;
    }
    nbkbonds = 0;
    sg = subgraf_new(at_data, na, alist);
    if (!sg)
    {
        TREAT_ERR(*err, 9037, "Not enough memory (polymers)");
        goto exit_function;
    }
    start = sg->orig2node[end_atom1]; end = sg->orig2node[end_atom2];
    if (start > end)
    {
        int tmp = end;
        end = start;
        start = tmp;
    }
    spf = subgraf_pathfinder_new(sg, at_data, start, end);
    if (!spf)
    {
        TREAT_ERR(*err, 9039, "Not enough memory (polymers)");
        goto exit_function;
    }
    spf->seen[0] = spf->start; spf->nseen = 1;    
    nbkbonds = 0;
    *nbkatoms = 0;
    subgraf_pathfinder_run(spf, 0, NULL, &nbkbonds, bkbonds, nbkatoms, bkatoms);
    subgraf_free(sg);
    subgraf_pathfinder_free(spf);
    *err = 0;
exit_function:
    if (bkbonds)
    {
        imat_free(maxbkbonds, bkbonds);
        bkbonds = NULL;
    }	
    return;
}
void OAD_CollectBackboneAtoms ( ORIG_ATOM_DATA * at_data , int na , int * alist , int end_atom1 , int end_atom2 , int * nbkatoms , int * bkatoms , int * err , char * pStrErr ) { int start = 0 , end = 0 ; subgraf * sg = NULL ; subgraf_pathfinder * spf = NULL ; int nbkbonds = 0 ; int * * bkbonds = NULL ; int maxbkbonds ; * nbkatoms = 0 ; maxbkbonds = at_data -> num_inp_bonds + 2 ; * err = imat_new ( maxbkbonds , 2 , & ( bkbonds ) ) ; if ( * err ) { TREAT_ERR ( * err , 9034 , " " ) ; goto exit_function ; } nbkbonds = 0 ; sg = subgraf_new ( at_data , na , alist ) ; if ( ! sg ) { TREAT_ERR ( * err , 9037 , " " ) ; goto exit_function ; } start = sg -> orig2node [ end_atom1 ] ; end = sg -> orig2node [ end_atom2 ] ; if ( start > end ) { int tmp = end ; end = start ; start = tmp ; } spf = subgraf_pathfinder_new ( sg , at_data , start , end ) ; if ( ! spf ) { TREAT_ERR ( * err , 9039 , " " ) ; goto exit_function ; } spf -> seen [ 0 ] = spf -> start ; spf -> nseen = 1 ; nbkbonds = 0 ; * nbkatoms = 0 ; subgraf_pathfinder_run ( spf , 0 , NULL , & nbkbonds , bkbonds , nbkatoms , bkatoms ) ; subgraf_free ( sg ) ; subgraf_pathfinder_free ( spf ) ; * err = 0 ; exit_function : if ( bkbonds ) { imat_free ( maxbkbonds , bkbonds ) ; bkbonds = NULL ; } return ; }
Collect all backbone atoms - of main chain(s), side chains being ignored
Collect all backbone atoms - of main chain ( s ) side chains being ignored
/* list of [breakable] backbone bonds	[ (a1,a2), (a3,a4), ... ]	*/