]> granicus.if.org Git - onig/commitdiff
add type OnigEndCallListItemType and onig_add_end_call().
authorK.Kosako <sndgk393@ybb.ne.jp>
Wed, 27 Nov 2013 02:03:53 +0000 (11:03 +0900)
committerK.Kosako <sndgk393@ybb.ne.jp>
Wed, 27 Nov 2013 02:03:53 +0000 (11:03 +0900)
regcomp.c
regint.h

index 995e1d886155958081df1cf0297ae647b0e54cab..d4d16c1b521fd62df42b5c1cb6d22ee40b1172ce 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -2,7 +2,7 @@
   regcomp.c -  Oniguruma (regular expression library)
 **********************************************************************/
 /*-
- * Copyright (c) 2002-2008  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2002-2013  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -5575,11 +5575,42 @@ onig_init(void)
 }
 
 
+static OnigEndCallListItemType* EndCallTop;
+
+extern void onig_add_end_call(void (*func)(void))
+{
+  OnigEndCallListItemType* item;
+
+  item = (OnigEndCallListItemType* )xmalloc(sizeof(*item));
+  if (item == 0) return ;
+
+  item->next = EndCallTop;
+  item->func = func;
+
+  EndCallTop = item;
+}
+
+static void
+exec_end_call_list(void)
+{
+  OnigEndCallListItemType* item = EndCallTop;
+  void (*func)(void);
+
+  while (EndCallTop != 0) {
+    func = EndCallTop->func;
+    (*func)();
+
+    EndCallTop = EndCallTop->next;
+  }
+}
+
 extern int
 onig_end(void)
 {
   THREAD_ATOMIC_START;
 
+  exec_end_call_list();
+
 #ifdef ONIG_DEBUG_STATISTICS
   onig_print_statistics(stderr);
 #endif
index a0ce4912d8cf54e6c9f7f253712769bafb4d2f89..0fba09bb584b0d5b99ca2cdcbff015fc555af16a 100644 (file)
--- a/regint.h
+++ b/regint.h
@@ -4,7 +4,7 @@
   regint.h -  Oniguruma (regular expression library)
 **********************************************************************/
 /*-
- * Copyright (c) 2002-2008  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2002-2013  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -750,6 +750,14 @@ typedef struct {
 #define IS_CODE_SB_WORD(enc,code) \
   (ONIGENC_IS_CODE_ASCII(code) && ONIGENC_IS_CODE_WORD(enc,code))
 
+typedef struct OnigEndCallListItem {
+  struct OnigEndCallListItem* next;
+  void (*func)(void);
+} OnigEndCallListItemType;
+
+extern void onig_add_end_call(void (*func)(void));
+
+
 #ifdef ONIG_DEBUG
 
 typedef struct {
@@ -760,6 +768,7 @@ typedef struct {
 
 extern OnigOpInfoType OnigOpInfo[];
 
+
 extern void onig_print_compiled_byte_code P_((FILE* f, UChar* bp, UChar** nextp, OnigEncoding enc));
 
 #ifdef ONIG_DEBUG_STATISTICS