2
2
#include <string.h>
3
3
4
4
#include "cmark-gfm_config.h"
5
+ #include "mutex.h"
5
6
#include "node.h"
6
7
#include "syntax_extension.h"
7
8
9
+ CMARK_DEFINE_LOCK (shift )
10
+
8
11
static void S_node_unlink (cmark_node * node );
9
12
10
13
#define NODE_MEM (node ) cmark_node_mem(node)
@@ -14,6 +17,8 @@ cmark_node__internal_flags CMARK_NODE__LAST_LINE_BLANK;
14
17
cmark_node__internal_flags CMARK_NODE__LAST_LINE_CHECKED ;
15
18
16
19
void cmark_register_node_flag (cmark_node__internal_flags * flags ) {
20
+ CMARK_INITIALIZE_AND_LOCK (shift );
21
+
17
22
static uint8_t shift = 0 ;
18
23
19
24
// flags should be a pointer to a global variable and this function
@@ -31,16 +36,20 @@ void cmark_register_node_flag(cmark_node__internal_flags *flags) {
31
36
32
37
* flags = (cmark_node__internal_flags )1 << shift ;
33
38
shift ++ ;
39
+
40
+ CMARK_UNLOCK (shift );
41
+ }
42
+
43
+ CMARK_DEFINE_ONCE (initialized );
44
+
45
+ static void initialize_standard_flags (void ) {
46
+ cmark_register_node_flag (& CMARK_NODE__OPEN );
47
+ cmark_register_node_flag (& CMARK_NODE__LAST_LINE_BLANK );
48
+ cmark_register_node_flag (& CMARK_NODE__LAST_LINE_CHECKED );
34
49
}
35
50
36
51
void cmark_init_standard_node_flags () {
37
- static int initialized = 0 ;
38
- if (!initialized ) {
39
- initialized = 1 ;
40
- cmark_register_node_flag (& CMARK_NODE__OPEN );
41
- cmark_register_node_flag (& CMARK_NODE__LAST_LINE_BLANK );
42
- cmark_register_node_flag (& CMARK_NODE__LAST_LINE_CHECKED );
43
- }
52
+ CMARK_RUN_ONCE (initialized , initialize_standard_flags );
44
53
}
45
54
46
55
bool cmark_node_can_contain_type (cmark_node * node , cmark_node_type child_type ) {
0 commit comments