dartsclone 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +1 -1
- data/CHANGELOG.md +3 -0
- data/LICENSE.txt +1 -1
- data/ext/dartsclone/dartscloneext.hpp +19 -4
- data/lib/dartsclone/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97644d2ac4c4641a5ece8c2a6f75286843955f3a6c8c777c54984a33d7f40ffa
|
4
|
+
data.tar.gz: 11d1bc54058b6e13a13ed115df887cdfc80488466815d873bc7219739ba40f92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0309acb6f96c43590c39cd1c2e11a47fe7ca35dbb8f9e8dbf71b5a5465607d561624837ea901ac60964c85453c50c8b6333c7a62cd477f48644056eabab60783'
|
7
|
+
data.tar.gz: cd63a1951b7f7bdd376ade80a3f978c45fc4c82e41c3418c3310182da5035b735c67189c932bdf6e1557d657d1415d3ee7df0dff39ab57e744d0d7d20c3d114a
|
data/.github/workflows/build.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
#ifndef DARTSCLONEEXT_HPP
|
2
2
|
#define DARTSCLONEEXT_HPP 1
|
3
3
|
|
4
|
+
#include <cstring>
|
5
|
+
|
4
6
|
#include <ruby.h>
|
5
7
|
#include <darts.h>
|
6
8
|
|
@@ -68,22 +70,26 @@ class RbDoubleArray
|
|
68
70
|
const int n_keys = RARRAY_LEN(_keys);
|
69
71
|
char** keys = (char**)ruby_xmalloc(n_keys * sizeof(char*));
|
70
72
|
int* values = _values == Qundef ? NULL : (int*)ruby_xmalloc(n_keys * sizeof(int));
|
73
|
+
VALUE key_str;
|
71
74
|
for (int i = 0; i < n_keys; i++) {
|
72
|
-
|
73
|
-
keys[i] = StringValueCStr(key_str);
|
75
|
+
key_str = rb_ary_entry(_keys, i);
|
76
|
+
keys[i] = strcpy((char*)ruby_xmalloc((RSTRING_LEN(key_str) + 1) * sizeof(char)), StringValueCStr(key_str));
|
74
77
|
if (_values != Qundef) values[i] = NUM2INT(rb_ary_entry(_values, i));
|
75
78
|
}
|
76
79
|
|
77
80
|
try {
|
78
81
|
get_double_array(self)->build(n_keys, keys, NULL, values);
|
79
82
|
} catch (Darts::Details::Exception e) {
|
83
|
+
for (int i = 0; i < n_keys; i++) ruby_xfree(keys[i]);
|
80
84
|
ruby_xfree(keys);
|
81
85
|
if (_values != Qundef) ruby_xfree(values);
|
82
86
|
rb_raise(rb_eRuntimeError, "%s", e.what());
|
83
87
|
return Qfalse;
|
84
88
|
}
|
89
|
+
for (int i = 0; i < n_keys; i++) ruby_xfree(keys[i]);
|
85
90
|
ruby_xfree(keys);
|
86
91
|
if (_values != Qundef) ruby_xfree(values);
|
92
|
+
RB_GC_GUARD(key_str);
|
87
93
|
return Qtrue;
|
88
94
|
}
|
89
95
|
|
@@ -97,13 +103,16 @@ class RbDoubleArray
|
|
97
103
|
rb_get_kwargs(kwargs, kwtable, 0, 3, kwvalues);
|
98
104
|
|
99
105
|
const char* filename = StringValueCStr(_filename);
|
100
|
-
|
106
|
+
VALUE _mode = kwvalues[0];
|
107
|
+
const char* mode = kwvalues[0] == Qundef ? "rb" : StringValueCStr(_mode);
|
101
108
|
const size_t offset = kwvalues[1] == Qundef ? 0 : NUM2SIZET(kwvalues[1]);
|
102
109
|
const size_t size = kwvalues[2] == Qundef ? 0 : NUM2SIZET(kwvalues[2]);
|
103
110
|
|
104
111
|
if (get_double_array(self)->open(filename, mode, offset, size) != 0) {
|
105
112
|
return Qfalse;
|
106
113
|
}
|
114
|
+
RB_GC_GUARD(_filename);
|
115
|
+
RB_GC_GUARD(_mode);
|
107
116
|
return Qtrue;
|
108
117
|
};
|
109
118
|
|
@@ -117,12 +126,15 @@ class RbDoubleArray
|
|
117
126
|
rb_get_kwargs(kwargs, kwtable, 0, 2, kwvalues);
|
118
127
|
|
119
128
|
const char* filename = StringValueCStr(_filename);
|
120
|
-
|
129
|
+
VALUE _mode = kwvalues[0];
|
130
|
+
const char* mode = kwvalues[0] == Qundef ? "wb" : StringValueCStr(_mode);
|
121
131
|
const size_t offset = kwvalues[1] == Qundef ? 0 : NUM2SIZET(kwvalues[1]);
|
122
132
|
|
123
133
|
if (get_double_array(self)->save(filename, mode, offset) != 0) {
|
124
134
|
return Qfalse;
|
125
135
|
}
|
136
|
+
RB_GC_GUARD(_filename);
|
137
|
+
RB_GC_GUARD(_mode);
|
126
138
|
return Qtrue;
|
127
139
|
};
|
128
140
|
|
@@ -137,6 +149,7 @@ class RbDoubleArray
|
|
137
149
|
const size_t total_sz = sz / get_double_array(self)->unit_size();
|
138
150
|
char* arr = StringValuePtr(bytes);
|
139
151
|
get_double_array(self)->set_array(arr, total_sz);
|
152
|
+
RB_GC_GUARD(bytes);
|
140
153
|
return Qnil;
|
141
154
|
};
|
142
155
|
|
@@ -160,6 +173,7 @@ class RbDoubleArray
|
|
160
173
|
|
161
174
|
Darts::DoubleArray::value_type value;
|
162
175
|
get_double_array(self)->exactMatchSearch(key, value, length, node_pos);
|
176
|
+
RB_GC_GUARD(_key);
|
163
177
|
return INT2NUM(value);
|
164
178
|
};
|
165
179
|
|
@@ -200,6 +214,7 @@ class RbDoubleArray
|
|
200
214
|
rb_ary_push(ret, values);
|
201
215
|
}
|
202
216
|
ruby_xfree(results);
|
217
|
+
RB_GC_GUARD(_key);
|
203
218
|
return ret;
|
204
219
|
};
|
205
220
|
|
data/lib/dartsclone/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dartsclone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yoshoku
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Darts-clone.rb is a Ruby binding for the Darts-clone.
|
14
14
|
email:
|