static int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, ses_ctx_t* ctx, ses_path_t** ppath)
{
- ses_path_t* path = *ppath;
ScfEcomponent* c;
ScfEline* el;
ScfEpin* np;
size_t i;
size_t j;
+ size_t k;
if (SCF_EDA_Status_OFF == rc->status)
return SCF_EDA_Status_OFF;
if (SCF_EDA_Transistor == rc->type && SCF_EDA_Transistor_E == rp->id)
return SCF_EDA_Path_OFF;
- if (!path) {
- path = ses_path_alloc();
- if (!path)
+ if (!*ppath) {
+ *ppath = ses_path_alloc();
+ if (!*ppath)
return -ENOMEM;
-
- *ppath = path;
}
- if (scf_vector_add(path->pins, rp) < 0)
+ if (scf_vector_add((*ppath)->pins, rp) < 0)
return -ENOMEM;
if (SCF_EDA_Transistor != rc->type || SCF_EDA_Transistor_E != rp->id)
continue;
}
- if (scf_vector_add(path->pins, np) < 0)
+ if (!*ppath) {
+ *ppath = ses_path_alloc();
+ if (!*ppath)
+ return -ENOMEM;
+ }
+
+ if (scf_vector_add((*ppath)->pins, np) < 0)
return -ENOMEM;
if (SCF_EDA_Transistor != rc->type || SCF_EDA_Transistor_E != np->id)
if (SCF_EDA_PIN_NEG & el->flags) {
scf_loge("neg l%ld\n\n", el->id);
- if (scf_vector_add(ctx->paths, path) < 0)
+ if (scf_vector_add(ctx->paths, *ppath) < 0)
return -ENOMEM;
- path->type = SES_PATH_MAIN;
-
- for (j = 0; j < path->pins->size; j++) {
- p = path->pins->data[j];
+ for (j = 0; j < (*ppath)->pins->size; j++) {
+ p = (*ppath)->pins->data[j];
p->pflag = 1;
}
if (p->pflag && p != np) {
scf_loge("branch: c%ld_p%ld, l%ld\n", c->id, p->id, el->id);
- ret = SCF_EDA_Path_TO;
- goto end;
+
+ if (scf_vector_add(ctx->paths, *ppath) < 0)
+ return -ENOMEM;
+
+ for (k = 0; k < (*ppath)->pins->size; k++) {
+ p = (*ppath)->pins->data[k];
+ p->pflag = 1;
+ }
+
+ ret = SCF_EDA_Path_TO;
+ *ppath = NULL;
+ break;
}
if (p->vflag)
if (SCF_EDA_Path_OFF == ret)
p->vflag = 0;
else if (SCF_EDA_Path_TO == ret)
- goto end;
+ break;
}
- if (ret > 0) {
+ if (SCF_EDA_Status_OFF == ret || SCF_EDA_Path_OFF == ret) {
if (*ppath)
scf_vector_del((*ppath)->pins, np);
}
}
- if (ret > 0) {
+ if (SCF_EDA_Status_OFF == ret || SCF_EDA_Path_OFF == ret) {
if (*ppath)
scf_vector_del((*ppath)->pins, rp);
return -ENOMEM;
}
- path->type = SES_PATH_BRANCH;
- path = NULL;
+ path = NULL;
}
if (path) {