chunkio 0.1.4 → 0.1.5

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: 328b09a0f74379b9a415ccefd4ac6bfc0cb8ff47ec1944ce99a02a1e91780066
4
- data.tar.gz: 39cbef7c28eae30b08aab87f436bcad8265b196079226535d2929dc9b885a68b
3
+ metadata.gz: 230de38a2734b474235db25f5d470783aeda36489e0a0f1fae42f25f360541ee
4
+ data.tar.gz: ee656bc59c3569a1790dae2a1e46c7f2a7e21b675d728956183cf12ff126f774
5
5
  SHA512:
6
- metadata.gz: 1e2f403020ea65060493f75e0c4785aa726946d01f370a57b96611b323cf9325a3c349be727a475b36ef1ab6763d1aaeca466c31277667d59d7000d04135a838
7
- data.tar.gz: 62dd1a7226e4c2c492cf74ce5c77c84e18210621e40bf934f2f092e2e61ee52eef6bd0125efa898411835ed3be2f423c89b00d73cb2da59b074afa6e6c74df62
6
+ metadata.gz: 6f3e0a1739be527f0a730ed3d908bc23807d49797e89ec62fda5227c3199f203021d853fd1776c1ea252b1b01ba9b6fbe5f0942c50f70bc4911bb927f1443846
7
+ data.tar.gz: 855dce6c8e2a8aaea5dee11516ad60445a107811d76e99c7c86d4fd02dff87ed2f867ff1db5cad9aa740d6492ad34c659bf7d185500df814301e701299ef25de
@@ -5,7 +5,7 @@
5
5
  #include <chunkio/chunkio.h>
6
6
  #include <chunkio/cio_meta.h>
7
7
 
8
- typedef struct chunkio_chunk {
8
+ typedef struct chunkio_chunk_type {
9
9
  struct cio_chunk* inner;
10
10
  int closed;
11
11
  int sync_mode; /* 0 is false, 1 is true */
@@ -20,30 +20,21 @@ static const rb_data_type_t chunkio_context_type =
20
20
  {
21
21
  "ChunkIO::Context",
22
22
  {0, (void (*)(void *))chunkio_context_free, 0,},
23
- 0, 0,
24
- #ifdef RUBY_TYPED_FREE_IMMEDIATELY
25
- RUBY_TYPED_FREE_IMMEDIATELY,
26
- #endif
23
+ 0, 0, 0
27
24
  };
28
25
 
29
26
  static const rb_data_type_t chunkio_stream_type =
30
27
  {
31
28
  "ChunkIO::Stream",
32
29
  {0, (void (*)(void *))chunkio_stream_free, 0,},
33
- 0, 0,
34
- #ifdef RUBY_TYPED_FREE_IMMEDIATELY
35
- RUBY_TYPED_FREE_IMMEDIATELY,
36
- #endif
30
+ 0, 0, 0
37
31
  };
38
32
 
39
33
  static const rb_data_type_t chunkio_chunk_type =
40
34
  {
41
35
  "ChunkIO::Chunk",
42
36
  {0, (void (*)(void *))chunkio_chunk_free, 0,}, /* TODO free ch->name and ch->head */
43
- 0, 0,
44
- #ifdef RUBY_TYPED_FREE_IMMEDIATELY
45
- RUBY_TYPED_FREE_IMMEDIATELY,
46
- #endif
37
+ 0, 0, 0
47
38
  };
48
39
 
49
40
  struct cio_ctx *UnwrapChunkIOContext(VALUE self);
@@ -6,24 +6,34 @@ void *chunkio_chunk_free(chunkio_chunk *ch)
6
6
  {
7
7
  if (ch->inner != NULL) {
8
8
  /*
9
- cio_stream can be freed before this line.
10
- but cio_chunk_close and cio_chunk_sync needs to stream->type.
9
+ `cio_stream` and `cio_ctx` can be freed before this line.
10
+ but cio_chunk_close and cio_chunk_sync needs them during freeing itself.
11
11
  So creating dummy object to work correctly.
12
- */
12
+ */
13
13
  struct cio_stream st;
14
14
  st.type = CIO_STORE_FS;
15
+ st.name = (char *)"stream";
15
16
  ch->inner->st = &st;
17
+
18
+ struct cio_ctx ct;
19
+ ct.flags = CIO_CHECKSUM;
20
+ ct.log_cb = NULL;
21
+ ch->inner->ctx = &ct;
22
+
16
23
  cio_chunk_sync(ch->inner);
17
24
  cio_chunk_close(ch->inner, CIO_FALSE);
18
25
  ch->inner = NULL;
19
26
  }
20
27
 
21
- xfree(ch);
28
+ if (ch != NULL) {
29
+ xfree(ch);
30
+ ch = NULL;
31
+ }
22
32
  }
23
33
 
24
34
  static VALUE chunkio_chunk_allocate_context(VALUE klass)
25
35
  {
26
- chunkio_chunk *c = (chunkio_chunk *)xmalloc(sizeof(chunkio_chunk));
36
+ chunkio_chunk *c = (chunkio_chunk *)xmalloc(sizeof(struct chunkio_chunk_type));
27
37
  c->inner = NULL;
28
38
  c->closed = 0;
29
39
  c->sync_mode = 0;
@@ -10,7 +10,6 @@ void *chunkio_stream_free(struct cio_stream *st)
10
10
  */
11
11
  if (st) {
12
12
  /* destroy stream */
13
- mk_list_del(&st->_head);
14
13
  free(st->name);
15
14
  free(st);
16
15
  st = NULL;
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ChunkIO
4
- VERSION = '0.1.4'
4
+ VERSION = '0.1.5'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chunkio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuta Iwama