usamin 7.7.6 → 7.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 578850ff19b39ff8950a5d31f890d78cef055935521637ab28cbcda311d1739d
4
- data.tar.gz: 95705ef10f8fc3dcdf3687d9670638a981c081154cbc1dcdd85b3cb7a9821683
3
+ metadata.gz: 7413ecd5a577b354f0a536da1b2bd451b5ea59e1b19d2c7875f34371769071f4
4
+ data.tar.gz: '08a17cb48a760174d1fb5bdbd70fbbb68b65ad1070e91b2cbbdde14452a74d49'
5
5
  SHA512:
6
- metadata.gz: d95d14dcdfa3578c75699f529e5d324ef47f4e4eba6961efd76136bcaee3b01d50f35cace24c018824de6b48a3cac96e1c0d1ad3c43a72e17f1a882847b6c4c7
7
- data.tar.gz: b4f9a8f2cef31b7e7dcfe1e876b59f9164322af8db9a7b970a944559c19d9c83d9490b5dd1c819b34f3f02ec1aa7f83003700c7c243a7af2d2ed96da9947c3cd
6
+ metadata.gz: 9bb85ee9718f07ef82f87992a38400159fb5601c9479e13718e89bb50e0d4c4a8acf61790efe4cf4a0fa3ab890e1650adf0749c570aebbd428f105cf6f41c4a9
7
+ data.tar.gz: b9a27406ab4d05ca2cae353e4627bd1c4cb5b01719f50d9c7f3600629bbdce37120467017dd8016b889d4b8fa0f1ccad24357c5bcb90816927e95226bc2baa38
@@ -10,6 +10,7 @@
10
10
  #include <rapidjson/writer.h>
11
11
  #include <rapidjson/prettywriter.h>
12
12
  #include <rapidjson/error/en.h>
13
+ #include <iostream>
13
14
 
14
15
  #if SIZEOF_VALUE < SIZEOF_VOIDP
15
16
  #error SIZEOF_VOIDP must not be greater than SIZEOF_VALUE.
@@ -81,35 +82,55 @@ static inline void check_array(UsaminValue *ptr) {
81
82
  }
82
83
 
83
84
 
84
- static VALUE usamin_free(UsaminValue **ptr) {
85
+ static void usamin_free(void *p) {
86
+ if (!p)
87
+ return;
88
+ UsaminValue **ptr = (UsaminValue**)p;
85
89
  if (*ptr)
86
90
  delete *ptr;
87
- ruby_xfree(ptr);
88
- return Qnil;
91
+ ruby_xfree(p);
89
92
  }
90
93
 
91
- static VALUE usamin_mark(UsaminValue **ptr) {
94
+ static void usamin_mark(void *p) {
95
+ if (!p)
96
+ return;
97
+ UsaminValue **ptr = (UsaminValue**)p;
92
98
  if (*ptr && (*ptr)->root_document != Qnil)
93
99
  rb_gc_mark((*ptr)->root_document);
94
- return Qnil;
95
100
  }
96
101
 
102
+ static size_t usamin_size(const void *p) {
103
+ if (!p)
104
+ return 0;
105
+ UsaminValue **ptr = (UsaminValue**)p;
106
+ size_t s = 0;
107
+ if (*ptr) {
108
+ s += sizeof(UsaminValue);
109
+ if ((*ptr)->free_flag)
110
+ s += ((rapidjson::Document*)(*ptr)->value)->GetAllocator().Capacity();
111
+ }
112
+ return s;
113
+ }
114
+
115
+ static const rb_data_type_t rb_usamin_value_type = { "UsaminValue", { usamin_mark, usamin_free, usamin_size }, nullptr, nullptr, RUBY_TYPED_FREE_IMMEDIATELY };
116
+
97
117
  static VALUE usamin_alloc(const VALUE klass) {
98
- UsaminValue** ptr = (UsaminValue**)ruby_xmalloc(sizeof(UsaminValue*));
118
+ UsaminValue** ptr;
119
+ VALUE ret = TypedData_Make_Struct(klass, UsaminValue*, &rb_usamin_value_type, ptr);
99
120
  *ptr = nullptr;
100
- return Data_Wrap_Struct(klass, usamin_mark, usamin_free, ptr);
121
+ return ret;
101
122
  }
102
123
 
103
124
 
104
125
  static inline UsaminValue* get_value(VALUE value) {
105
126
  UsaminValue** ptr;
106
- Data_Get_Struct(value, UsaminValue*, ptr);
127
+ TypedData_Get_Struct(value, UsaminValue*, &rb_usamin_value_type, ptr);
107
128
  return *ptr;
108
129
  }
109
130
 
110
131
  static inline void set_value(VALUE value, UsaminValue *usamin) {
111
132
  UsaminValue **ptr;
112
- Data_Get_Struct(value, UsaminValue*, ptr);
133
+ TypedData_Get_Struct(value, UsaminValue*, &rb_usamin_value_type, ptr);
113
134
  *ptr = usamin;
114
135
  }
115
136
 
@@ -1,3 +1,3 @@
1
1
  module Usamin
2
- VERSION = "7.7.6"
2
+ VERSION = "7.7.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usamin
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.7.6
4
+ version: 7.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ishotihadus
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-05 00:00:00.000000000 Z
11
+ date: 2018-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler