triez 1.0.2 → 1.0.3

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
  SHA1:
3
- metadata.gz: 88f05351da6b711cefe44c0e5060f5c04380e5b6
4
- data.tar.gz: 41ff89af13fd30d8def221fa396d1097816f39c1
3
+ metadata.gz: 331dc65dd70b83b8986fe4d07b5242e1cd8264d4
4
+ data.tar.gz: 8fb8aabd4adabb3388723640b1382bd6f6accae1
5
5
  SHA512:
6
- metadata.gz: b8047e6c017a559b9916dfcdf235f39b560e486d190a14963a32c2cf565725f128e26c2b3f07d83273fe79ab566349220cc048a1eec347f35aa6308832887124
7
- data.tar.gz: 8f64787cd1db06201d18e5ddc235d960a5ab6d08a63c212e13619094c47bc688feb59ababc950ec4e70bc8382ff89a255154a03913eb16ac784690aeb2d6f787
6
+ metadata.gz: 5bcae2775f541197179171682c27e19e59cdedf92d46da2293b25c2150fdce768a49976479fd400cc318075630e4a191ada4a7041380c2676d6cf0a3d4d98a33
7
+ data.tar.gz: 9e80343627118747019fe21c5087c979bd33149bdfbad0a056cc291a5cb63f4b3893fa915edc85574c4cfe95aefa82789d7867106208f9fa534cbe6eea7c911f
data/changes CHANGED
@@ -1,3 +1,8 @@
1
+ 1.0.3
2
+
3
+ 2014-09-14
4
+ fix a segfault. see https://github.com/luikore/triez/issues/3. thanks @canadaduane for reporting this.
5
+
1
6
  1.0.2
2
7
 
3
8
  2013-06-01
@@ -15,7 +15,6 @@
15
15
 
16
16
  const double ahtable_max_load_factor = 100000.0; /* arbitrary large number => don't resize */
17
17
  const size_t ahtable_initial_size = 4096;
18
- static const uint16_t LONG_KEYLEN_MASK = 0x7fff;
19
18
 
20
19
  static size_t keylen(slot_t s) {
21
20
  if (0x1 & *s) {
@@ -112,8 +112,9 @@ static inline int hattrie_clrval(hattrie_t *T, node_ptr n)
112
112
  }
113
113
 
114
114
  /* find node in trie */
115
- static node_ptr hattrie_find(hattrie_t* T, const char **key, size_t *len)
115
+ static node_ptr hattrie_find(hattrie_t* T, const char **key, size_t *len, int* found)
116
116
  {
117
+ *found = 1;
117
118
  node_ptr parent = T->root;
118
119
  assert(*parent.flag & NODE_TYPE_TRIE);
119
120
 
@@ -124,7 +125,7 @@ static node_ptr hattrie_find(hattrie_t* T, const char **key, size_t *len)
124
125
  /* if the trie node consumes value, use it */
125
126
  if (*node.flag & NODE_TYPE_TRIE) {
126
127
  if (!(node.t->flag & NODE_HAS_VAL)) {
127
- node.flag = NULL;
128
+ *found = 0;
128
129
  }
129
130
  return node;
130
131
  }
@@ -394,8 +395,9 @@ value_t* hattrie_get(hattrie_t* T, const char* key, size_t len)
394
395
  value_t* hattrie_tryget(hattrie_t* T, const char* key, size_t len)
395
396
  {
396
397
  /* find node for given key */
397
- node_ptr node = hattrie_find(T, &key, &len);
398
- if (node.flag == NULL) {
398
+ int found;
399
+ node_ptr node = hattrie_find(T, &key, &len, &found);
400
+ if (!found) {
399
401
  return NULL;
400
402
  }
401
403
 
@@ -468,8 +470,9 @@ int hattrie_del(hattrie_t* T, const char* key, size_t len)
468
470
  assert(*parent.flag & NODE_TYPE_TRIE);
469
471
 
470
472
  /* find node for deletion */
471
- node_ptr node = hattrie_find(T, &key, &len);
472
- if (node.flag == NULL) {
473
+ int found;
474
+ node_ptr node = hattrie_find(T, &key, &len, &found);
475
+ if (!found) {
473
476
  return -1;
474
477
  }
475
478
 
@@ -648,7 +651,8 @@ hattrie_iter_t* hattrie_iter_begin(const hattrie_t* T, bool sorted)
648
651
 
649
652
  hattrie_iter_t* hattrie_iter_with_prefix(const hattrie_t* T, bool sorted, const char* prefix, size_t prefix_len)
650
653
  {
651
- node_ptr node = hattrie_find((hattrie_t*)T, &prefix, &prefix_len);
654
+ int found;
655
+ node_ptr node = hattrie_find((hattrie_t*)T, &prefix, &prefix_len, &found);
652
656
 
653
657
  hattrie_iter_t* i = malloc_or_die(sizeof(hattrie_iter_t));
654
658
  i->T = T;
@@ -1,7 +1,7 @@
1
1
  require_relative "../ext/triez"
2
2
 
3
3
  class Triez
4
- VERSION = '1.0.2'
4
+ VERSION = '1.0.3'
5
5
 
6
6
  private :_internal_set_type
7
7
  private :_internal_search
@@ -213,4 +213,11 @@ class TriezTest < Test::Unit::TestCase
213
213
  end
214
214
  assert_equal '一锅鸡', lcs
215
215
  end
216
+
217
+ def test_should_not_segfault_when_search_with_prefix
218
+ t = Triez.new
219
+ # bursts when 16384
220
+ 16_385.times{ |i| t["a#{i}"] = rand(10)+1 }
221
+ t.search_with_prefix("a")
222
+ end
216
223
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: triez
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zete Lui
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-31 00:00:00.000000000 Z
11
+ date: 2014-09-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: fast, efficient, unicode aware HAT trie with prefix / suffix support.
14
14
  email:
@@ -17,17 +17,13 @@ extensions:
17
17
  - ext/extconf.rb
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - copying
21
20
  - changes
22
- - readme.md
23
- - lib/triez.rb
24
- - test/triez_test.rb
25
- - ext/triez.cc
21
+ - copying
26
22
  - ext/common.h
27
23
  - ext/extconf.rb
24
+ - ext/hat-trie/COPYING
28
25
  - ext/hat-trie/ahtable.c
29
26
  - ext/hat-trie/ahtable.h
30
- - ext/hat-trie/COPYING
31
27
  - ext/hat-trie/hat-trie.c
32
28
  - ext/hat-trie/hat-trie.h
33
29
  - ext/hat-trie/misc.c
@@ -35,6 +31,10 @@ files:
35
31
  - ext/hat-trie/murmurhash3.c
36
32
  - ext/hat-trie/murmurhash3.h
37
33
  - ext/hat-trie/pstdint.h
34
+ - ext/triez.cc
35
+ - lib/triez.rb
36
+ - readme.md
37
+ - test/triez_test.rb
38
38
  homepage: https://github.com/luikore/triez
39
39
  licenses: []
40
40
  metadata: {}
@@ -54,9 +54,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
54
  version: '0'
55
55
  requirements: []
56
56
  rubyforge_project:
57
- rubygems_version: 2.0.3
57
+ rubygems_version: 2.4.1
58
58
  signing_key:
59
59
  specification_version: 4
60
60
  summary: fast, efficient, unicode aware HAT trie with prefix / suffix support
61
61
  test_files: []
62
- has_rdoc: false