markly 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93a192bb4cf0e216365ffa17fc619ecc726cb7cbd9a3661ae3357ce5a8dbb1c4
4
- data.tar.gz: ec39190db7ad173cdbbcddd73850fc07faa578d37892217cedd329efad060610
3
+ metadata.gz: 27b98de3f04fbba3681df9356148129c3adb335740846ba638a4fb2790029e9e
4
+ data.tar.gz: c6bdd14cff454a313050128e4b4f32e1b7db2306581d8fde7475ccd9021fac36
5
5
  SHA512:
6
- metadata.gz: 5668b9796316e769f73a6d97c495116e3361b9cc0a12fa92c8ec35461954a63d7568e8975af4720d060605ccb2ecdcc96bf123da2074271216a2e55e3afa378d
7
- data.tar.gz: 132e25acaad81e6953c4c25a206dc6e37ba0f2cff3176887fb81882817edd81fa6c2a8eb24cf274046635b30f1179832f2daeb00ec78e18f4afb537166e4aab7
6
+ metadata.gz: 69a8a8366b7b3eb19d08c1cedd839c5a0a3ec15d3c0e3be1f80e9adcd4a7849704a733249aebb86771a822a3e4b0dbb4a5643b208597be9316c7282f5b6d471a
7
+ data.tar.gz: 1540db6af546c59fff663ab5f056519fdf48523e56c35a28281e3d5c34f75b4c2d0e0176666af4453b87b16faefeb19880da511067468a34d648d97c15d1a2ff
@@ -41,11 +41,13 @@ static VALUE sym_right;
41
41
  static VALUE sym_center;
42
42
 
43
43
  static void rb_Markly_Node_free(void *data) {
44
- // It's important that the `free` function does not inspect the node data, as it may be part of a tree that was already freed.
45
- cmark_node *node = (cmark_node*)data;
46
-
47
- if (cmark_node_parent(node) == NULL) {
48
- cmark_node_free(node);
44
+ // If a parent of this node is already freed, `rb_Markly_Node_freed` will ensure all the nodes are nullified.
45
+ if (data) {
46
+ cmark_node *node = (cmark_node*)data;
47
+
48
+ if (cmark_node_parent(node) == NULL) {
49
+ cmark_node_free(node);
50
+ }
49
51
  }
50
52
  }
51
53
 
@@ -79,6 +81,12 @@ static const rb_data_type_t rb_Markly_Node_Type = {
79
81
  .flags = RUBY_TYPED_FREE_IMMEDIATELY,
80
82
  };
81
83
 
84
+ static void rb_Markly_Node_freed(cmark_mem *mem, void *user_data) {
85
+ VALUE self = (VALUE)user_data;
86
+
87
+ RTYPEDDATA_DATA(self) = NULL;
88
+ }
89
+
82
90
  static VALUE rb_Markly_Node_wrap(cmark_node *node) {
83
91
  if (node == NULL)
84
92
  return Qnil;
@@ -91,6 +99,7 @@ static VALUE rb_Markly_Node_wrap(cmark_node *node) {
91
99
 
92
100
  VALUE self = TypedData_Wrap_Struct(rb_Markly_Node, &rb_Markly_Node_Type, node);
93
101
  cmark_node_set_user_data(node, (void *)self);
102
+ cmark_node_set_user_data_free_func(node, rb_Markly_Node_freed);
94
103
 
95
104
  return self;
96
105
  }
@@ -121,16 +130,6 @@ static const rb_data_type_t rb_Markly_Parser_Type = {
121
130
  .flags = RUBY_TYPED_FREE_IMMEDIATELY,
122
131
  };
123
132
 
124
- static VALUE rb_Markly_Parser_root(VALUE self) {
125
- cmark_parser *parser = NULL;
126
-
127
- TypedData_Get_Struct(self, cmark_parser, &rb_Markly_Parser_Type, parser);
128
-
129
- assert(parser != NULL);
130
-
131
- return rb_Markly_Node_wrap(parser->root);
132
- }
133
-
134
133
  static VALUE rb_Markly_Parser_alloc(VALUE self) {
135
134
  return TypedData_Wrap_Struct(self, &rb_Markly_Parser_Type, NULL);
136
135
  }
@@ -1193,7 +1192,6 @@ __attribute__((visibility("default"))) void Init_markly() {
1193
1192
  rb_define_method(rb_Markly_Parser, "initialize", rb_Markly_Parser_initialize, 1);
1194
1193
  rb_define_method(rb_Markly_Parser, "enable", rb_Markly_Parser_enable, 1);
1195
1194
  rb_define_method(rb_Markly_Parser, "parse", rb_Markly_Parser_parse, 1);
1196
- rb_define_method(rb_Markly_Parser, "root", rb_Markly_Parser_root, 0);
1197
1195
 
1198
1196
  rb_Markly_Node = rb_define_class_under(rb_Markly, "Node", rb_cObject);
1199
1197
  rb_define_singleton_method(rb_Markly_Node, "new", rb_node_new, 1);
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Markly
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-06-13 00:00:00.000000000 Z
13
+ date: 2020-06-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bake