Commit a5939e1f38c3604d3b1205f2edd8a26965729eec

tokyovania 2022-08-10T13:50:17

add Proc_lib clean

diff --git a/.gitignore b/.gitignore
index 6c2af04..ee34611 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,4 @@ config.mk
 /lib/*/.*.log
 *.la
 *.lo
+*.o
\ No newline at end of file
diff --git a/README.md b/README.md
index 32e2d03..07160cc 100644
--- a/README.md
+++ b/README.md
@@ -19,6 +19,11 @@ sudo apt install bmake gcc libbsd-dev libglfw3-dev libgtk-3-dev libreadline-dev 
 make
 make install
 ```
+## Usage
+```
+. ./home-rtbuf
+rtbuf
+```
 
 ## Issues
 
diff --git a/librtbuf/lib.h b/librtbuf/lib.h
index 619ed25..f4780a7 100644
--- a/librtbuf/lib.h
+++ b/librtbuf/lib.h
@@ -99,10 +99,12 @@ s_rtbuf_lib * rtbuf_lib_new ();
 void          rtbuf_lib_print (const s_rtbuf_lib *lib);
 void          rtbuf_lib_print_long (unsigned int i);
 
+void rtbuf_lib_proc_clean (s_rtbuf_proc *proc);
 void rtbuf_lib_proc_init_in (s_rtbuf_proc *proc,
                              s_rtbuf_lib_proc_in *in);
 void rtbuf_lib_proc_init_out (s_rtbuf_proc *proc,
                               s_rtbuf_lib_proc_out *out);
 void rtbuf_lib_proc_init (s_rtbuf_proc *proc, s_rtbuf_lib_proc *x);
 
+
 #endif
diff --git a/librtbuf/rtbuf.c b/librtbuf/rtbuf.c
index f37e42c..1110a17 100644
--- a/librtbuf/rtbuf.c
+++ b/librtbuf/rtbuf.c
@@ -65,6 +65,7 @@ void librtbuf_shutdown ()
   rtbuf_lib_shutdown();
   rtbuf_proc_shutdown();
   rtbuf_type_shutdown();
+  data_alloc_clean(&g_rtbuf_alloc);
   g_rtbuf = 0;
   libdata_shutdown();
 }
diff --git a/librtbuf/rtbuf_lib.c b/librtbuf/rtbuf_lib.c
index b8f7858..f24aa92 100644
--- a/librtbuf/rtbuf_lib.c
+++ b/librtbuf/rtbuf_lib.c
@@ -105,6 +105,7 @@ void rtbuf_lib_delete (s_rtbuf_lib *rl)
   assert(rl);
   if (rl->proc) {
     rtbuf_proc_delete(rl->proc);
+    rtbuf_lib_proc_clean(rl->proc);
     rl->proc = 0;
     if (rl->unload)
       rl->unload(rl);
@@ -253,8 +254,6 @@ void rtbuf_lib_proc_init_in (s_rtbuf_proc *proc,
   proc->bytes = offset;
   proc->type.bits = offset * 8;
   proc->type.type = DATA_TYPE_BITS;
-  data_alloc_init(&proc->alloc, &proc->type, RTBUF_INSTANCE_MAX,
-                  NULL, NULL);
 }
 
 void rtbuf_lib_proc_init_out (s_rtbuf_proc *proc,
@@ -296,6 +295,13 @@ void rtbuf_lib_proc_init (s_rtbuf_proc *proc, s_rtbuf_lib_proc *x)
   proc->stop = x->stop;
   rtbuf_lib_proc_init_out(proc, x->out);
   rtbuf_lib_proc_init_in(proc, x->in);
+  data_alloc_init(&proc->alloc, &proc->type, RTBUF_INSTANCE_MAX,
+                  NULL, NULL);
+}
+
+void rtbuf_lib_proc_clean (s_rtbuf_proc *proc)
+{
+  data_alloc_clean(&proc->alloc);
 }
 
 void rtbuf_lib_print (const s_rtbuf_lib *lib)