From ad2f8caae5952eea2de9ffb65d96d93b25173c7d Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Wed, 26 Jul 2023 22:40:54 +0800 Subject: [PATCH] ses_path_alloc() --- ses_core.h | 17 +++++++++++++++++ ses_steps.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/ses_core.h b/ses_core.h index 7841e47..eb023c0 100644 --- a/ses_core.h +++ b/ses_core.h @@ -5,6 +5,7 @@ #include"scf_vector.h" typedef struct ses_step_s ses_step_t; +typedef struct ses_path_s ses_path_t; typedef struct ses_edge_s ses_edge_t; typedef struct ses_ctx_s ses_ctx_t; @@ -18,6 +19,20 @@ struct ses_edge_s ScfEpin* p1; }; +#define SES_PATH_MAIN 0 +#define SES_PATH_BRANCH 1 +#define SES_PATH_BRIDGE 2 + +struct ses_path_s +{ + scf_vector_t* pins; + + scf_vector_t* childs; + ses_path_t* parent; + + int type; +}; + struct ses_ctx_s { scf_vector_t* paths; @@ -32,6 +47,8 @@ struct ses_step_s void* priv; }; +ses_path_t* ses_path_alloc(); +void ses_path_free (ses_path_t* path); ses_ctx_t* ses_ctx_alloc(); void ses_ctx_free (ses_ctx_t* ctx); diff --git a/ses_steps.c b/ses_steps.c index 62a0b2b..72678b2 100644 --- a/ses_steps.c +++ b/ses_steps.c @@ -35,6 +35,36 @@ static ses_step_t* ses_steps[] = &ses_step_output, }; +ses_path_t* ses_path_alloc() +{ + ses_path_t* path = calloc(1, sizeof(ses_path_t)); + if (!path) + return NULL; + + path->pins = scf_vector_alloc(); + if (!path->pins) { + free(path); + return NULL; + } + + return path; +} + +void ses_path_free(ses_path_t* path) +{ + if (path) { + if (path->pins) + scf_vector_free(path->pins); + + if (path->childs) { + scf_vector_clear(path->childs, ( void (*)(void*) )ses_path_free); + scf_vector_free (path->childs); + } + + free(path); + } +} + ses_ctx_t* ses_ctx_alloc() { ses_ctx_t* ctx = calloc(1, sizeof(ses_ctx_t)); -- 2.25.1