msgpack 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,4 +1,10 @@
1
1
 
2
+ 2012-02-14 version 0.5.3:
3
+
4
+ * Fixed segfault problem on Buffer#clear (reuse rmem internal fragment optimization)
5
+ * Fixed segfault problem on Buffer (rmem free code)
6
+
7
+
2
8
  2012-02-07 version 0.5.2:
3
9
 
4
10
  * Fixed invalid pack/unpack on 32bit architecture such as Win32
@@ -72,7 +72,8 @@ static void _msgpack_buffer_chunk_destroy(msgpack_buffer_chunk_t* c)
72
72
  free(c->mem);
73
73
  }
74
74
  /* no needs to update rmem_owner because chunks will not be
75
- * free()ed and thus *rmem_owner = NULL is always valid. */
75
+ * free()ed (left in free_list) and thus *rmem_owner is
76
+ * always valid. */
76
77
  #else
77
78
  free(c->mem);
78
79
  #endif
@@ -282,8 +283,8 @@ static inline void _msgpack_buffer_add_new_chunk(msgpack_buffer_t* b)
282
283
 
283
284
  #ifndef DISABLE_RMEM
284
285
  #ifndef DISABLE_RMEM_REUSE_INTERNAL_FRAGMENT
285
- if(b->rmem_owner == &b->tail.mem) {
286
- /* reuse unused rmem */
286
+ if(b->rmem_last == b->tail_buffer_end) {
287
+ /* reuse unused rmem space */
287
288
  size_t unused = b->tail_buffer_end - b->tail.last;
288
289
  b->rmem_last -= unused;
289
290
  }
@@ -76,7 +76,7 @@ void* _msgpack_rmem_alloc2(msgpack_rmem_t* pm)
76
76
  return pm->head.pages;
77
77
  }
78
78
 
79
- static inline void handle_empty_chunk(msgpack_rmem_t* pm, msgpack_rmem_chunk_t* c)
79
+ void _msgpack_rmem_chunk_free(msgpack_rmem_t* pm, msgpack_rmem_chunk_t* c)
80
80
  {
81
81
  if(pm->array_first->mask == 0xffffffff) {
82
82
  /* free and move to last */
@@ -92,19 +92,3 @@ static inline void handle_empty_chunk(msgpack_rmem_t* pm, msgpack_rmem_chunk_t*
92
92
  *c = tmp;
93
93
  }
94
94
 
95
- bool _msgpack_rmem_free2(msgpack_rmem_t* pm, void* mem)
96
- {
97
- /* search from last */
98
- msgpack_rmem_chunk_t* c = pm->array_last - 1;
99
- msgpack_rmem_chunk_t* before_first = pm->array_first - 1;
100
- for(; c != before_first; c--) {
101
- if(_msgpack_rmem_chunk_try_free(c, mem)) {
102
- if(c != pm->array_first && c->mask == 0xffffffff) {
103
- handle_empty_chunk(pm, c);
104
- }
105
- return true;
106
- }
107
- }
108
- return false;
109
- }
110
-
@@ -82,17 +82,26 @@ static inline void* msgpack_rmem_alloc(msgpack_rmem_t* pm)
82
82
  return _msgpack_rmem_alloc2(pm);
83
83
  }
84
84
 
85
- bool _msgpack_rmem_free2(msgpack_rmem_t* pm, void* mem);
85
+ void _msgpack_rmem_chunk_free(msgpack_rmem_t* pm, msgpack_rmem_chunk_t* c);
86
86
 
87
87
  static inline bool msgpack_rmem_free(msgpack_rmem_t* pm, void* mem)
88
88
  {
89
89
  if(_msgpack_rmem_chunk_try_free(&pm->head, mem)) {
90
90
  return true;
91
91
  }
92
- if(pm->array_last == pm->array_end) {
93
- return false;
92
+
93
+ /* search from last */
94
+ msgpack_rmem_chunk_t* c = pm->array_last - 1;
95
+ msgpack_rmem_chunk_t* before_first = pm->array_first - 1;
96
+ for(; c != before_first; c--) {
97
+ if(_msgpack_rmem_chunk_try_free(c, mem)) {
98
+ if(c != pm->array_first && c->mask == 0xffffffff) {
99
+ _msgpack_rmem_chunk_free(pm, c);
100
+ }
101
+ return true;
102
+ }
94
103
  }
95
- return _msgpack_rmem_free2(pm, mem);
104
+ return false;
96
105
  }
97
106
 
98
107
 
@@ -1,3 +1,3 @@
1
1
  module MessagePack
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
@@ -210,7 +210,7 @@ describe Buffer do
210
210
  }
211
211
  end
212
212
 
213
- it 'random write' do
213
+ it 'random write and flush' do
214
214
  r = Random.new(random_seed)
215
215
 
216
216
  50.times {
@@ -233,5 +233,24 @@ describe Buffer do
233
233
  io.string.should == s
234
234
  }
235
235
  end
236
+
237
+ it 'random write and clear' do
238
+ r = Random.new(random_seed)
239
+ b = Buffer.new
240
+
241
+ 50.times {
242
+ s = r.bytes(0)
243
+
244
+ r.rand(4).times do
245
+ n = r.rand(1024*1400)
246
+ x = r.bytes(n)
247
+ s << x
248
+ b.write(x)
249
+ end
250
+
251
+ b.size.should == s.size
252
+ b.clear
253
+ }
254
+ end
236
255
  end
237
256
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: msgpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-07 00:00:00.000000000 Z
12
+ date: 2013-02-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler