ses_path_alloc()
authoryu.dongliang <18588496441@163.com>
Wed, 26 Jul 2023 14:40:54 +0000 (22:40 +0800)
committeryu.dongliang <18588496441@163.com>
Wed, 26 Jul 2023 14:40:54 +0000 (22:40 +0800)
ses_core.h
ses_steps.c

index 7841e47c3e5da76d88d7b1f9f07071d629a6a2c3..eb023c0bacf49d0208f9f5626977f6ca2c67c4c8 100644 (file)
@@ -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);
index 62a0b2b5bc4e1f31be9a1b70481a1fe7df312938..72678b243126b2a404fdff8b824bcf8263ebf56b 100644 (file)
@@ -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));