slyphon-zookeeper 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -6,4 +6,5 @@
6
6
  Makefile
7
7
  pkg
8
8
  zookeeper.gemspec
9
- Gemfile.lock
9
+ Gemfile.*
10
+ tmp/
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ v0.9.2 More efficient and simpler wrappers for GIL release
2
+
3
+ * After a code review by Andrew Wason (rectalogic), use a much simpler
4
+ technique for creating the arg structs and passing them to the
5
+ zkrb_gvl_* functions. No malloc(), no free(), no problem.
6
+
1
7
  v0.9.1 see v0.8.4 notes, same patch
2
8
 
3
9
  v0.9.0 RELEASE THE KRAK..er, GIL!!
data/README.markdown CHANGED
@@ -7,6 +7,9 @@ such as locks, have a look at [ZK](https://github.com/slyphon/zk) (also
7
7
  available is [ZK-EventMachine](https://github.com/slyphon/zk-eventmachine) for
8
8
  those who prefer async).
9
9
 
10
+ Unfortunately, since this is a fork of twitter/zookeeper, we don't have our own
11
+ Issues tracker. Issues should be filed under [ZK](https://github.com/slyphon/zk/issues).
12
+
10
13
  ## License
11
14
 
12
15
  Copyright 2008 Phillip Pearson, and 2010 Twitter, Inc. Licensed under the
data/Rakefile CHANGED
@@ -1,29 +1,62 @@
1
1
  # def gemset_name
2
2
  # ENV.fetch('GEM_HOME').split('@').last
3
3
  # end
4
- #
4
+
5
+ GEM_FILES = FileList['slyphon-zookeeper-*.gem']
6
+
5
7
  namespace :mb do
6
- task :build_gems do
7
- sh "rvm 1.8.7 do gem build slyphon-zookeeper.gemspec"
8
- ENV['JAVA_GEM'] = '1'
9
- sh "rvm 1.8.7 do gem build slyphon-zookeeper.gemspec"
8
+ namespace :gems do
9
+ task :build do
10
+ sh "rvm 1.8.7 do gem build slyphon-zookeeper.gemspec"
11
+ ENV['JAVA_GEM'] = '1'
12
+ sh "rvm 1.8.7 do gem build slyphon-zookeeper.gemspec"
13
+ end
14
+
15
+ task :push do
16
+ GEM_FILES.each do |gem|
17
+ sh "gem push #{gem}"
18
+ end
19
+ end
20
+
21
+ task :clean do
22
+ rm_rf GEM_FILES
23
+ end
24
+
25
+ task :all => [:build, :push, :clean]
10
26
  end
11
27
  end
12
28
 
13
29
  gemset_name = 'zookeeper'
14
30
 
31
+ directory 'tmp'
32
+
33
+ # this nonsense w/ tmp and the Gemfile is a bundler optimization
34
+
35
+ GEMSPEC_LINK = 'tmp/slyphon-zookeeper.gemspec'
36
+
37
+ file GEMSPEC_LINK => 'tmp' do
38
+ ln_s '../slyphon-zookeeper.gemspec', GEMSPEC_LINK
39
+ end
15
40
 
16
- %w[1.8.7 1.9.2 1.9.3 jruby rbx].each do |ns_name|
41
+ %w[1.8.7 1.9.2 jruby rbx 1.9.3].each do |ns_name|
17
42
  rvm_ruby = (ns_name == 'rbx') ? "rbx-2.0.testing" : ns_name
18
43
 
19
44
  ruby_with_gemset = "#{rvm_ruby}@#{gemset_name}"
20
45
 
21
46
  create_gemset_name = "mb:#{ns_name}:create_gemset"
22
47
  clobber_task_name = "mb:#{ns_name}:clobber"
48
+ clean_task_name = "mb:#{ns_name}:clean"
23
49
  build_task_name = "mb:#{ns_name}:build"
24
50
  bundle_task_name = "mb:#{ns_name}:bundle_install"
25
51
  rspec_task_name = "mb:#{ns_name}:run_rspec"
26
52
 
53
+ phony_gemfile_link_name = File.expand_path("tmp/Gemfile.#{ns_name}")
54
+
55
+ file phony_gemfile_link_name => GEMSPEC_LINK do
56
+ # apparently, rake doesn't deal with symlinks intelligently :P
57
+ ln_s('../Gemfile', phony_gemfile_link_name) unless File.exists?(phony_gemfile_link_name)
58
+ end
59
+
27
60
  task create_gemset_name do
28
61
  sh "rvm #{rvm_ruby} do rvm gemset create #{gemset_name}"
29
62
  end
@@ -36,7 +69,15 @@ gemset_name = 'zookeeper'
36
69
  end
37
70
  end
38
71
 
39
- task build_task_name => [create_gemset_name, clobber_task_name] do
72
+ task clean_task_name do
73
+ unless rvm_ruby == 'jruby'
74
+ cd 'ext' do
75
+ sh "rake clean"
76
+ end
77
+ end
78
+ end
79
+
80
+ task build_task_name => [create_gemset_name, clean_task_name] do
40
81
  unless rvm_ruby == 'jruby'
41
82
  cd 'ext' do
42
83
  sh "rvm #{ruby_with_gemset} do rake build"
@@ -44,13 +85,12 @@ gemset_name = 'zookeeper'
44
85
  end
45
86
  end
46
87
 
47
- task bundle_task_name => build_task_name do
48
- rm_f 'Gemfile.lock'
49
- sh "rvm #{ruby_with_gemset} do bundle install"
88
+ task bundle_task_name => [phony_gemfile_link_name, build_task_name] do
89
+ sh "rvm #{ruby_with_gemset} do bundle install --gemfile #{phony_gemfile_link_name}"
50
90
  end
51
91
 
52
92
  task rspec_task_name => bundle_task_name do
53
- sh "rvm #{ruby_with_gemset} do bundle exec rspec spec --fail-fast"
93
+ sh "rvm #{ruby_with_gemset} do env BUNDLE_GEMFILE=#{phony_gemfile_link_name} bundle exec rspec spec --fail-fast"
54
94
  end
55
95
 
56
96
  task "mb:#{ns_name}" => rspec_task_name
@@ -58,6 +98,23 @@ gemset_name = 'zookeeper'
58
98
  task "mb:test_all" => rspec_task_name
59
99
  end
60
100
 
101
+ task :default => 'mb:1.9.3'
102
+
103
+ task :clean do
104
+ rm_rf 'tmp'
105
+ end
106
+
107
+ # cargo culted from http://blog.flavorjon.es/2009/06/easily-valgrind-gdb-your-ruby-c.html
108
+ VALGRIND_BASIC_OPTS = '--num-callers=50 --error-limit=no --partial-loads-ok=yes --undef-value-errors=no'
109
+
110
+ task 'valgrind' do
111
+ cd 'ext' do
112
+ sh "rake clean build"
113
+ end
114
+
115
+ sh "valgrind #{VALGRIND_BASIC_OPTS} bundle exec rspec spec"
116
+ end
117
+
61
118
  namespace :build do
62
119
  task :clean do
63
120
  cd 'ext' do
data/ext/Rakefile CHANGED
@@ -29,6 +29,10 @@ end
29
29
 
30
30
  ZKRB_WRAPPER = %w[zkrb_wrapper.c zkrb_wrapper.h]
31
31
 
32
+
33
+ task :wrappers => ZKRB_WRAPPER
34
+
35
+
32
36
  task :clobber => :clean do
33
37
  rm_rf %w[Makefile c lib bin include]
34
38
  end
@@ -35,29 +35,21 @@ we want
35
35
  int valuelen, const struct ACL_vector *acl, int flags,
36
36
  string_completion_t completion, const void *data) {
37
37
 
38
- int rc;
39
- zkrb_zoo_acreate_args_t *ptr = malloc(sizeof(zkrb_zoo_acreate_args_t));
40
- check_mem(ptr);
41
-
42
- ptr->rc = 0;
43
- ptr->zh = zh;
44
- ptr->path = path;
45
- ptr->value = value;
46
- ptr->valuelen = valuelen;
47
- ptr->acl = acl;
48
- ptr->flags = flags;
49
- ptr->completion = completion;
50
- ptr->data = data;
51
-
52
- rb_thread_blocking_region(zkrb_gvl_zoo_acreate, (void *)ptr, RUBY_UBF_IO, 0);
53
-
54
- rc = ptr->rc;
55
- free(ptr);
56
- return rc;
57
-
58
- error:
59
- free(ptr);
60
- return -1;
38
+ zkrb_zoo_acreate_args_t args = {
39
+ .rc = ZKRB_FAIL,
40
+ .zh = zh,
41
+ .path = path,
42
+ .value = value,
43
+ .valuelen = valuelen,
44
+ .acl = acl,
45
+ .flags = flags,
46
+ .completion = completion,
47
+ .data = data
48
+ };
49
+
50
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_acreate, (void *)&args);
51
+
52
+ return args.rc;
61
53
  }
62
54
 
63
55
  =end
@@ -156,43 +148,35 @@ class CallingFunction
156
148
  @fn_signature ||= "int #{name}(#{typed_args.join(', ')})"
157
149
  end
158
150
 
159
- def ptr_lines
160
- @ptr_lines = (
161
- lines = ["ptr->rc = rc;"]
162
- lines += member_names.map { |n| "ptr->#{n} = #{n};" }
163
- lines.map! { |n| " #{n}" }
164
- lines.join("\n")
165
- )
151
+ def initializer_lines
152
+ @initializer_lines ||= member_names.map { |n| " .#{n} = #{n}" }.join(",\n")
166
153
  end
167
154
 
168
155
  def top
169
156
  <<-EOS
170
157
  // wrapper that calls #{zoo_fn_name} via #{wrapper_fn.name} inside rb_thread_blocking_region
171
158
  #{fn_signature} {
172
- int rc = ZKRB_FAIL;
173
- #{struct.name} *ptr = malloc(sizeof(#{struct.name}));
174
- check_mem(ptr);
159
+ #{struct.name} args = {
160
+ .rc = ZKRB_FAIL,
161
+ #{initializer_lines}
162
+ };
175
163
  EOS
176
164
  end
177
165
 
178
166
  def rb_thread_blocking_region_call
179
- " zkrb_thread_blocking_region(#{wrapper_fn.name}, (void *)ptr);"
167
+ " zkrb_thread_blocking_region(#{wrapper_fn.name}, (void *)&args);"
180
168
  end
181
169
 
182
170
  def bottom
183
171
  <<-EOS
184
172
 
185
- rc = ptr->rc;
186
-
187
- error:
188
- free(ptr);
189
- return rc;
173
+ return args.rc;
190
174
  }
191
175
  EOS
192
176
  end
193
177
 
194
178
  def body
195
- @body ||= [top, ptr_lines, nil, rb_thread_blocking_region_call, bottom].join("\n")
179
+ @body ||= [top, rb_thread_blocking_region_call, bottom].join("\n")
196
180
  end
197
181
  end
198
182
 
@@ -209,6 +193,8 @@ class GeneratedCode < Struct.new(:structs, :wrapper_fns, :calling_fns)
209
193
  new.tap do |code|
210
194
  while true
211
195
  break unless text =~ REGEXP
196
+ text = $~.post_match
197
+
212
198
  zoo_fn_name, argstr = $1
213
199
  argstr = $2
214
200
 
@@ -228,8 +214,6 @@ class GeneratedCode < Struct.new(:structs, :wrapper_fns, :calling_fns)
228
214
  code.structs << struct
229
215
  code.wrapper_fns << wrapper_fn
230
216
  code.calling_fns << calling_fn
231
-
232
- text = $~.post_match
233
217
  end
234
218
  end
235
219
  end
data/ext/zkrb_wrapper.c CHANGED
@@ -21,20 +21,14 @@ static VALUE zkrb_gvl_zoo_recv_timeout(void *data) {
21
21
 
22
22
  // wrapper that calls zoo_recv_timeout via zkrb_gvl_zoo_recv_timeout inside rb_thread_blocking_region
23
23
  int zkrb_call_zoo_recv_timeout(zhandle_t *zh) {
24
- int rc = ZKRB_FAIL;
25
- zkrb_zoo_recv_timeout_args_t *ptr = malloc(sizeof(zkrb_zoo_recv_timeout_args_t));
26
- check_mem(ptr);
24
+ zkrb_zoo_recv_timeout_args_t args = {
25
+ .rc = ZKRB_FAIL,
26
+ .zh = zh
27
+ };
27
28
 
28
- ptr->rc = rc;
29
- ptr->zh = zh;
29
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_recv_timeout, (void *)&args);
30
30
 
31
- zkrb_thread_blocking_region(zkrb_gvl_zoo_recv_timeout, (void *)ptr);
32
-
33
- rc = ptr->rc;
34
-
35
- error:
36
- free(ptr);
37
- return rc;
31
+ return args.rc;
38
32
  }
39
33
 
40
34
 
@@ -46,20 +40,14 @@ static VALUE zkrb_gvl_zoo_state(void *data) {
46
40
 
47
41
  // wrapper that calls zoo_state via zkrb_gvl_zoo_state inside rb_thread_blocking_region
48
42
  int zkrb_call_zoo_state(zhandle_t *zh) {
49
- int rc = ZKRB_FAIL;
50
- zkrb_zoo_state_args_t *ptr = malloc(sizeof(zkrb_zoo_state_args_t));
51
- check_mem(ptr);
52
-
53
- ptr->rc = rc;
54
- ptr->zh = zh;
55
-
56
- zkrb_thread_blocking_region(zkrb_gvl_zoo_state, (void *)ptr);
43
+ zkrb_zoo_state_args_t args = {
44
+ .rc = ZKRB_FAIL,
45
+ .zh = zh
46
+ };
57
47
 
58
- rc = ptr->rc;
48
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_state, (void *)&args);
59
49
 
60
- error:
61
- free(ptr);
62
- return rc;
50
+ return args.rc;
63
51
  }
64
52
 
65
53
 
@@ -71,27 +59,21 @@ static VALUE zkrb_gvl_zoo_acreate(void *data) {
71
59
 
72
60
  // wrapper that calls zoo_acreate via zkrb_gvl_zoo_acreate inside rb_thread_blocking_region
73
61
  int zkrb_call_zoo_acreate(zhandle_t *zh, const char *path, const char *value, int valuelen, const struct ACL_vector *acl, int flags, string_completion_t completion, const void *data) {
74
- int rc = ZKRB_FAIL;
75
- zkrb_zoo_acreate_args_t *ptr = malloc(sizeof(zkrb_zoo_acreate_args_t));
76
- check_mem(ptr);
62
+ zkrb_zoo_acreate_args_t args = {
63
+ .rc = ZKRB_FAIL,
64
+ .zh = zh,
65
+ .path = path,
66
+ .value = value,
67
+ .valuelen = valuelen,
68
+ .acl = acl,
69
+ .flags = flags,
70
+ .completion = completion,
71
+ .data = data
72
+ };
77
73
 
78
- ptr->rc = rc;
79
- ptr->zh = zh;
80
- ptr->path = path;
81
- ptr->value = value;
82
- ptr->valuelen = valuelen;
83
- ptr->acl = acl;
84
- ptr->flags = flags;
85
- ptr->completion = completion;
86
- ptr->data = data;
74
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_acreate, (void *)&args);
87
75
 
88
- zkrb_thread_blocking_region(zkrb_gvl_zoo_acreate, (void *)ptr);
89
-
90
- rc = ptr->rc;
91
-
92
- error:
93
- free(ptr);
94
- return rc;
76
+ return args.rc;
95
77
  }
96
78
 
97
79
 
@@ -103,24 +85,18 @@ static VALUE zkrb_gvl_zoo_adelete(void *data) {
103
85
 
104
86
  // wrapper that calls zoo_adelete via zkrb_gvl_zoo_adelete inside rb_thread_blocking_region
105
87
  int zkrb_call_zoo_adelete(zhandle_t *zh, const char *path, int version, void_completion_t completion, const void *data) {
106
- int rc = ZKRB_FAIL;
107
- zkrb_zoo_adelete_args_t *ptr = malloc(sizeof(zkrb_zoo_adelete_args_t));
108
- check_mem(ptr);
109
-
110
- ptr->rc = rc;
111
- ptr->zh = zh;
112
- ptr->path = path;
113
- ptr->version = version;
114
- ptr->completion = completion;
115
- ptr->data = data;
116
-
117
- zkrb_thread_blocking_region(zkrb_gvl_zoo_adelete, (void *)ptr);
88
+ zkrb_zoo_adelete_args_t args = {
89
+ .rc = ZKRB_FAIL,
90
+ .zh = zh,
91
+ .path = path,
92
+ .version = version,
93
+ .completion = completion,
94
+ .data = data
95
+ };
118
96
 
119
- rc = ptr->rc;
97
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_adelete, (void *)&args);
120
98
 
121
- error:
122
- free(ptr);
123
- return rc;
99
+ return args.rc;
124
100
  }
125
101
 
126
102
 
@@ -132,24 +108,18 @@ static VALUE zkrb_gvl_zoo_aexists(void *data) {
132
108
 
133
109
  // wrapper that calls zoo_aexists via zkrb_gvl_zoo_aexists inside rb_thread_blocking_region
134
110
  int zkrb_call_zoo_aexists(zhandle_t *zh, const char *path, int watch, stat_completion_t completion, const void *data) {
135
- int rc = ZKRB_FAIL;
136
- zkrb_zoo_aexists_args_t *ptr = malloc(sizeof(zkrb_zoo_aexists_args_t));
137
- check_mem(ptr);
111
+ zkrb_zoo_aexists_args_t args = {
112
+ .rc = ZKRB_FAIL,
113
+ .zh = zh,
114
+ .path = path,
115
+ .watch = watch,
116
+ .completion = completion,
117
+ .data = data
118
+ };
138
119
 
139
- ptr->rc = rc;
140
- ptr->zh = zh;
141
- ptr->path = path;
142
- ptr->watch = watch;
143
- ptr->completion = completion;
144
- ptr->data = data;
120
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_aexists, (void *)&args);
145
121
 
146
- zkrb_thread_blocking_region(zkrb_gvl_zoo_aexists, (void *)ptr);
147
-
148
- rc = ptr->rc;
149
-
150
- error:
151
- free(ptr);
152
- return rc;
122
+ return args.rc;
153
123
  }
154
124
 
155
125
 
@@ -161,25 +131,19 @@ static VALUE zkrb_gvl_zoo_awexists(void *data) {
161
131
 
162
132
  // wrapper that calls zoo_awexists via zkrb_gvl_zoo_awexists inside rb_thread_blocking_region
163
133
  int zkrb_call_zoo_awexists(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, stat_completion_t completion, const void *data) {
164
- int rc = ZKRB_FAIL;
165
- zkrb_zoo_awexists_args_t *ptr = malloc(sizeof(zkrb_zoo_awexists_args_t));
166
- check_mem(ptr);
167
-
168
- ptr->rc = rc;
169
- ptr->zh = zh;
170
- ptr->path = path;
171
- ptr->watcher = watcher;
172
- ptr->watcherCtx = watcherCtx;
173
- ptr->completion = completion;
174
- ptr->data = data;
175
-
176
- zkrb_thread_blocking_region(zkrb_gvl_zoo_awexists, (void *)ptr);
134
+ zkrb_zoo_awexists_args_t args = {
135
+ .rc = ZKRB_FAIL,
136
+ .zh = zh,
137
+ .path = path,
138
+ .watcher = watcher,
139
+ .watcherCtx = watcherCtx,
140
+ .completion = completion,
141
+ .data = data
142
+ };
177
143
 
178
- rc = ptr->rc;
144
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_awexists, (void *)&args);
179
145
 
180
- error:
181
- free(ptr);
182
- return rc;
146
+ return args.rc;
183
147
  }
184
148
 
185
149
 
@@ -191,24 +155,18 @@ static VALUE zkrb_gvl_zoo_aget(void *data) {
191
155
 
192
156
  // wrapper that calls zoo_aget via zkrb_gvl_zoo_aget inside rb_thread_blocking_region
193
157
  int zkrb_call_zoo_aget(zhandle_t *zh, const char *path, int watch, data_completion_t completion, const void *data) {
194
- int rc = ZKRB_FAIL;
195
- zkrb_zoo_aget_args_t *ptr = malloc(sizeof(zkrb_zoo_aget_args_t));
196
- check_mem(ptr);
158
+ zkrb_zoo_aget_args_t args = {
159
+ .rc = ZKRB_FAIL,
160
+ .zh = zh,
161
+ .path = path,
162
+ .watch = watch,
163
+ .completion = completion,
164
+ .data = data
165
+ };
197
166
 
198
- ptr->rc = rc;
199
- ptr->zh = zh;
200
- ptr->path = path;
201
- ptr->watch = watch;
202
- ptr->completion = completion;
203
- ptr->data = data;
167
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_aget, (void *)&args);
204
168
 
205
- zkrb_thread_blocking_region(zkrb_gvl_zoo_aget, (void *)ptr);
206
-
207
- rc = ptr->rc;
208
-
209
- error:
210
- free(ptr);
211
- return rc;
169
+ return args.rc;
212
170
  }
213
171
 
214
172
 
@@ -220,25 +178,19 @@ static VALUE zkrb_gvl_zoo_awget(void *data) {
220
178
 
221
179
  // wrapper that calls zoo_awget via zkrb_gvl_zoo_awget inside rb_thread_blocking_region
222
180
  int zkrb_call_zoo_awget(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, data_completion_t completion, const void *data) {
223
- int rc = ZKRB_FAIL;
224
- zkrb_zoo_awget_args_t *ptr = malloc(sizeof(zkrb_zoo_awget_args_t));
225
- check_mem(ptr);
226
-
227
- ptr->rc = rc;
228
- ptr->zh = zh;
229
- ptr->path = path;
230
- ptr->watcher = watcher;
231
- ptr->watcherCtx = watcherCtx;
232
- ptr->completion = completion;
233
- ptr->data = data;
234
-
235
- zkrb_thread_blocking_region(zkrb_gvl_zoo_awget, (void *)ptr);
181
+ zkrb_zoo_awget_args_t args = {
182
+ .rc = ZKRB_FAIL,
183
+ .zh = zh,
184
+ .path = path,
185
+ .watcher = watcher,
186
+ .watcherCtx = watcherCtx,
187
+ .completion = completion,
188
+ .data = data
189
+ };
236
190
 
237
- rc = ptr->rc;
191
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_awget, (void *)&args);
238
192
 
239
- error:
240
- free(ptr);
241
- return rc;
193
+ return args.rc;
242
194
  }
243
195
 
244
196
 
@@ -250,26 +202,20 @@ static VALUE zkrb_gvl_zoo_aset(void *data) {
250
202
 
251
203
  // wrapper that calls zoo_aset via zkrb_gvl_zoo_aset inside rb_thread_blocking_region
252
204
  int zkrb_call_zoo_aset(zhandle_t *zh, const char *path, const char *buffer, int buflen, int version, stat_completion_t completion, const void *data) {
253
- int rc = ZKRB_FAIL;
254
- zkrb_zoo_aset_args_t *ptr = malloc(sizeof(zkrb_zoo_aset_args_t));
255
- check_mem(ptr);
205
+ zkrb_zoo_aset_args_t args = {
206
+ .rc = ZKRB_FAIL,
207
+ .zh = zh,
208
+ .path = path,
209
+ .buffer = buffer,
210
+ .buflen = buflen,
211
+ .version = version,
212
+ .completion = completion,
213
+ .data = data
214
+ };
256
215
 
257
- ptr->rc = rc;
258
- ptr->zh = zh;
259
- ptr->path = path;
260
- ptr->buffer = buffer;
261
- ptr->buflen = buflen;
262
- ptr->version = version;
263
- ptr->completion = completion;
264
- ptr->data = data;
216
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_aset, (void *)&args);
265
217
 
266
- zkrb_thread_blocking_region(zkrb_gvl_zoo_aset, (void *)ptr);
267
-
268
- rc = ptr->rc;
269
-
270
- error:
271
- free(ptr);
272
- return rc;
218
+ return args.rc;
273
219
  }
274
220
 
275
221
 
@@ -281,24 +227,18 @@ static VALUE zkrb_gvl_zoo_aget_children(void *data) {
281
227
 
282
228
  // wrapper that calls zoo_aget_children via zkrb_gvl_zoo_aget_children inside rb_thread_blocking_region
283
229
  int zkrb_call_zoo_aget_children(zhandle_t *zh, const char *path, int watch, strings_completion_t completion, const void *data) {
284
- int rc = ZKRB_FAIL;
285
- zkrb_zoo_aget_children_args_t *ptr = malloc(sizeof(zkrb_zoo_aget_children_args_t));
286
- check_mem(ptr);
287
-
288
- ptr->rc = rc;
289
- ptr->zh = zh;
290
- ptr->path = path;
291
- ptr->watch = watch;
292
- ptr->completion = completion;
293
- ptr->data = data;
294
-
295
- zkrb_thread_blocking_region(zkrb_gvl_zoo_aget_children, (void *)ptr);
230
+ zkrb_zoo_aget_children_args_t args = {
231
+ .rc = ZKRB_FAIL,
232
+ .zh = zh,
233
+ .path = path,
234
+ .watch = watch,
235
+ .completion = completion,
236
+ .data = data
237
+ };
296
238
 
297
- rc = ptr->rc;
239
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_aget_children, (void *)&args);
298
240
 
299
- error:
300
- free(ptr);
301
- return rc;
241
+ return args.rc;
302
242
  }
303
243
 
304
244
 
@@ -310,25 +250,19 @@ static VALUE zkrb_gvl_zoo_awget_children(void *data) {
310
250
 
311
251
  // wrapper that calls zoo_awget_children via zkrb_gvl_zoo_awget_children inside rb_thread_blocking_region
312
252
  int zkrb_call_zoo_awget_children(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, strings_completion_t completion, const void *data) {
313
- int rc = ZKRB_FAIL;
314
- zkrb_zoo_awget_children_args_t *ptr = malloc(sizeof(zkrb_zoo_awget_children_args_t));
315
- check_mem(ptr);
253
+ zkrb_zoo_awget_children_args_t args = {
254
+ .rc = ZKRB_FAIL,
255
+ .zh = zh,
256
+ .path = path,
257
+ .watcher = watcher,
258
+ .watcherCtx = watcherCtx,
259
+ .completion = completion,
260
+ .data = data
261
+ };
316
262
 
317
- ptr->rc = rc;
318
- ptr->zh = zh;
319
- ptr->path = path;
320
- ptr->watcher = watcher;
321
- ptr->watcherCtx = watcherCtx;
322
- ptr->completion = completion;
323
- ptr->data = data;
263
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_awget_children, (void *)&args);
324
264
 
325
- zkrb_thread_blocking_region(zkrb_gvl_zoo_awget_children, (void *)ptr);
326
-
327
- rc = ptr->rc;
328
-
329
- error:
330
- free(ptr);
331
- return rc;
265
+ return args.rc;
332
266
  }
333
267
 
334
268
 
@@ -340,24 +274,18 @@ static VALUE zkrb_gvl_zoo_aget_children2(void *data) {
340
274
 
341
275
  // wrapper that calls zoo_aget_children2 via zkrb_gvl_zoo_aget_children2 inside rb_thread_blocking_region
342
276
  int zkrb_call_zoo_aget_children2(zhandle_t *zh, const char *path, int watch, strings_stat_completion_t completion, const void *data) {
343
- int rc = ZKRB_FAIL;
344
- zkrb_zoo_aget_children2_args_t *ptr = malloc(sizeof(zkrb_zoo_aget_children2_args_t));
345
- check_mem(ptr);
346
-
347
- ptr->rc = rc;
348
- ptr->zh = zh;
349
- ptr->path = path;
350
- ptr->watch = watch;
351
- ptr->completion = completion;
352
- ptr->data = data;
353
-
354
- zkrb_thread_blocking_region(zkrb_gvl_zoo_aget_children2, (void *)ptr);
277
+ zkrb_zoo_aget_children2_args_t args = {
278
+ .rc = ZKRB_FAIL,
279
+ .zh = zh,
280
+ .path = path,
281
+ .watch = watch,
282
+ .completion = completion,
283
+ .data = data
284
+ };
355
285
 
356
- rc = ptr->rc;
286
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_aget_children2, (void *)&args);
357
287
 
358
- error:
359
- free(ptr);
360
- return rc;
288
+ return args.rc;
361
289
  }
362
290
 
363
291
 
@@ -369,25 +297,19 @@ static VALUE zkrb_gvl_zoo_awget_children2(void *data) {
369
297
 
370
298
  // wrapper that calls zoo_awget_children2 via zkrb_gvl_zoo_awget_children2 inside rb_thread_blocking_region
371
299
  int zkrb_call_zoo_awget_children2(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, strings_stat_completion_t completion, const void *data) {
372
- int rc = ZKRB_FAIL;
373
- zkrb_zoo_awget_children2_args_t *ptr = malloc(sizeof(zkrb_zoo_awget_children2_args_t));
374
- check_mem(ptr);
300
+ zkrb_zoo_awget_children2_args_t args = {
301
+ .rc = ZKRB_FAIL,
302
+ .zh = zh,
303
+ .path = path,
304
+ .watcher = watcher,
305
+ .watcherCtx = watcherCtx,
306
+ .completion = completion,
307
+ .data = data
308
+ };
375
309
 
376
- ptr->rc = rc;
377
- ptr->zh = zh;
378
- ptr->path = path;
379
- ptr->watcher = watcher;
380
- ptr->watcherCtx = watcherCtx;
381
- ptr->completion = completion;
382
- ptr->data = data;
310
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_awget_children2, (void *)&args);
383
311
 
384
- zkrb_thread_blocking_region(zkrb_gvl_zoo_awget_children2, (void *)ptr);
385
-
386
- rc = ptr->rc;
387
-
388
- error:
389
- free(ptr);
390
- return rc;
312
+ return args.rc;
391
313
  }
392
314
 
393
315
 
@@ -399,23 +321,17 @@ static VALUE zkrb_gvl_zoo_async(void *data) {
399
321
 
400
322
  // wrapper that calls zoo_async via zkrb_gvl_zoo_async inside rb_thread_blocking_region
401
323
  int zkrb_call_zoo_async(zhandle_t *zh, const char *path, string_completion_t completion, const void *data) {
402
- int rc = ZKRB_FAIL;
403
- zkrb_zoo_async_args_t *ptr = malloc(sizeof(zkrb_zoo_async_args_t));
404
- check_mem(ptr);
405
-
406
- ptr->rc = rc;
407
- ptr->zh = zh;
408
- ptr->path = path;
409
- ptr->completion = completion;
410
- ptr->data = data;
411
-
412
- zkrb_thread_blocking_region(zkrb_gvl_zoo_async, (void *)ptr);
324
+ zkrb_zoo_async_args_t args = {
325
+ .rc = ZKRB_FAIL,
326
+ .zh = zh,
327
+ .path = path,
328
+ .completion = completion,
329
+ .data = data
330
+ };
413
331
 
414
- rc = ptr->rc;
332
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_async, (void *)&args);
415
333
 
416
- error:
417
- free(ptr);
418
- return rc;
334
+ return args.rc;
419
335
  }
420
336
 
421
337
 
@@ -427,23 +343,17 @@ static VALUE zkrb_gvl_zoo_aget_acl(void *data) {
427
343
 
428
344
  // wrapper that calls zoo_aget_acl via zkrb_gvl_zoo_aget_acl inside rb_thread_blocking_region
429
345
  int zkrb_call_zoo_aget_acl(zhandle_t *zh, const char *path, acl_completion_t completion, const void *data) {
430
- int rc = ZKRB_FAIL;
431
- zkrb_zoo_aget_acl_args_t *ptr = malloc(sizeof(zkrb_zoo_aget_acl_args_t));
432
- check_mem(ptr);
346
+ zkrb_zoo_aget_acl_args_t args = {
347
+ .rc = ZKRB_FAIL,
348
+ .zh = zh,
349
+ .path = path,
350
+ .completion = completion,
351
+ .data = data
352
+ };
433
353
 
434
- ptr->rc = rc;
435
- ptr->zh = zh;
436
- ptr->path = path;
437
- ptr->completion = completion;
438
- ptr->data = data;
354
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_aget_acl, (void *)&args);
439
355
 
440
- zkrb_thread_blocking_region(zkrb_gvl_zoo_aget_acl, (void *)ptr);
441
-
442
- rc = ptr->rc;
443
-
444
- error:
445
- free(ptr);
446
- return rc;
356
+ return args.rc;
447
357
  }
448
358
 
449
359
 
@@ -455,25 +365,19 @@ static VALUE zkrb_gvl_zoo_aset_acl(void *data) {
455
365
 
456
366
  // wrapper that calls zoo_aset_acl via zkrb_gvl_zoo_aset_acl inside rb_thread_blocking_region
457
367
  int zkrb_call_zoo_aset_acl(zhandle_t *zh, const char *path, int version, struct ACL_vector *acl, void_completion_t completion, const void *data) {
458
- int rc = ZKRB_FAIL;
459
- zkrb_zoo_aset_acl_args_t *ptr = malloc(sizeof(zkrb_zoo_aset_acl_args_t));
460
- check_mem(ptr);
461
-
462
- ptr->rc = rc;
463
- ptr->zh = zh;
464
- ptr->path = path;
465
- ptr->version = version;
466
- ptr->acl = acl;
467
- ptr->completion = completion;
468
- ptr->data = data;
368
+ zkrb_zoo_aset_acl_args_t args = {
369
+ .rc = ZKRB_FAIL,
370
+ .zh = zh,
371
+ .path = path,
372
+ .version = version,
373
+ .acl = acl,
374
+ .completion = completion,
375
+ .data = data
376
+ };
469
377
 
470
- zkrb_thread_blocking_region(zkrb_gvl_zoo_aset_acl, (void *)ptr);
378
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_aset_acl, (void *)&args);
471
379
 
472
- rc = ptr->rc;
473
-
474
- error:
475
- free(ptr);
476
- return rc;
380
+ return args.rc;
477
381
  }
478
382
 
479
383
 
@@ -485,25 +389,19 @@ static VALUE zkrb_gvl_zoo_add_auth(void *data) {
485
389
 
486
390
  // wrapper that calls zoo_add_auth via zkrb_gvl_zoo_add_auth inside rb_thread_blocking_region
487
391
  int zkrb_call_zoo_add_auth(zhandle_t *zh, const char* scheme, const char* cert, int certLen, void_completion_t completion, const void *data) {
488
- int rc = ZKRB_FAIL;
489
- zkrb_zoo_add_auth_args_t *ptr = malloc(sizeof(zkrb_zoo_add_auth_args_t));
490
- check_mem(ptr);
491
-
492
- ptr->rc = rc;
493
- ptr->zh = zh;
494
- ptr->scheme = scheme;
495
- ptr->cert = cert;
496
- ptr->certLen = certLen;
497
- ptr->completion = completion;
498
- ptr->data = data;
392
+ zkrb_zoo_add_auth_args_t args = {
393
+ .rc = ZKRB_FAIL,
394
+ .zh = zh,
395
+ .scheme = scheme,
396
+ .cert = cert,
397
+ .certLen = certLen,
398
+ .completion = completion,
399
+ .data = data
400
+ };
499
401
 
500
- zkrb_thread_blocking_region(zkrb_gvl_zoo_add_auth, (void *)ptr);
402
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_add_auth, (void *)&args);
501
403
 
502
- rc = ptr->rc;
503
-
504
- error:
505
- free(ptr);
506
- return rc;
404
+ return args.rc;
507
405
  }
508
406
 
509
407
 
@@ -515,27 +413,21 @@ static VALUE zkrb_gvl_zoo_create(void *data) {
515
413
 
516
414
  // wrapper that calls zoo_create via zkrb_gvl_zoo_create inside rb_thread_blocking_region
517
415
  int zkrb_call_zoo_create(zhandle_t *zh, const char *path, const char *value, int valuelen, const struct ACL_vector *acl, int flags, char *path_buffer, int path_buffer_len) {
518
- int rc = ZKRB_FAIL;
519
- zkrb_zoo_create_args_t *ptr = malloc(sizeof(zkrb_zoo_create_args_t));
520
- check_mem(ptr);
521
-
522
- ptr->rc = rc;
523
- ptr->zh = zh;
524
- ptr->path = path;
525
- ptr->value = value;
526
- ptr->valuelen = valuelen;
527
- ptr->acl = acl;
528
- ptr->flags = flags;
529
- ptr->path_buffer = path_buffer;
530
- ptr->path_buffer_len = path_buffer_len;
416
+ zkrb_zoo_create_args_t args = {
417
+ .rc = ZKRB_FAIL,
418
+ .zh = zh,
419
+ .path = path,
420
+ .value = value,
421
+ .valuelen = valuelen,
422
+ .acl = acl,
423
+ .flags = flags,
424
+ .path_buffer = path_buffer,
425
+ .path_buffer_len = path_buffer_len
426
+ };
531
427
 
532
- zkrb_thread_blocking_region(zkrb_gvl_zoo_create, (void *)ptr);
428
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_create, (void *)&args);
533
429
 
534
- rc = ptr->rc;
535
-
536
- error:
537
- free(ptr);
538
- return rc;
430
+ return args.rc;
539
431
  }
540
432
 
541
433
 
@@ -547,22 +439,16 @@ static VALUE zkrb_gvl_zoo_delete(void *data) {
547
439
 
548
440
  // wrapper that calls zoo_delete via zkrb_gvl_zoo_delete inside rb_thread_blocking_region
549
441
  int zkrb_call_zoo_delete(zhandle_t *zh, const char *path, int version) {
550
- int rc = ZKRB_FAIL;
551
- zkrb_zoo_delete_args_t *ptr = malloc(sizeof(zkrb_zoo_delete_args_t));
552
- check_mem(ptr);
553
-
554
- ptr->rc = rc;
555
- ptr->zh = zh;
556
- ptr->path = path;
557
- ptr->version = version;
442
+ zkrb_zoo_delete_args_t args = {
443
+ .rc = ZKRB_FAIL,
444
+ .zh = zh,
445
+ .path = path,
446
+ .version = version
447
+ };
558
448
 
559
- zkrb_thread_blocking_region(zkrb_gvl_zoo_delete, (void *)ptr);
449
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_delete, (void *)&args);
560
450
 
561
- rc = ptr->rc;
562
-
563
- error:
564
- free(ptr);
565
- return rc;
451
+ return args.rc;
566
452
  }
567
453
 
568
454
 
@@ -574,23 +460,17 @@ static VALUE zkrb_gvl_zoo_exists(void *data) {
574
460
 
575
461
  // wrapper that calls zoo_exists via zkrb_gvl_zoo_exists inside rb_thread_blocking_region
576
462
  int zkrb_call_zoo_exists(zhandle_t *zh, const char *path, int watch, struct Stat *stat) {
577
- int rc = ZKRB_FAIL;
578
- zkrb_zoo_exists_args_t *ptr = malloc(sizeof(zkrb_zoo_exists_args_t));
579
- check_mem(ptr);
580
-
581
- ptr->rc = rc;
582
- ptr->zh = zh;
583
- ptr->path = path;
584
- ptr->watch = watch;
585
- ptr->stat = stat;
463
+ zkrb_zoo_exists_args_t args = {
464
+ .rc = ZKRB_FAIL,
465
+ .zh = zh,
466
+ .path = path,
467
+ .watch = watch,
468
+ .stat = stat
469
+ };
586
470
 
587
- zkrb_thread_blocking_region(zkrb_gvl_zoo_exists, (void *)ptr);
471
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_exists, (void *)&args);
588
472
 
589
- rc = ptr->rc;
590
-
591
- error:
592
- free(ptr);
593
- return rc;
473
+ return args.rc;
594
474
  }
595
475
 
596
476
 
@@ -602,24 +482,18 @@ static VALUE zkrb_gvl_zoo_wexists(void *data) {
602
482
 
603
483
  // wrapper that calls zoo_wexists via zkrb_gvl_zoo_wexists inside rb_thread_blocking_region
604
484
  int zkrb_call_zoo_wexists(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, struct Stat *stat) {
605
- int rc = ZKRB_FAIL;
606
- zkrb_zoo_wexists_args_t *ptr = malloc(sizeof(zkrb_zoo_wexists_args_t));
607
- check_mem(ptr);
608
-
609
- ptr->rc = rc;
610
- ptr->zh = zh;
611
- ptr->path = path;
612
- ptr->watcher = watcher;
613
- ptr->watcherCtx = watcherCtx;
614
- ptr->stat = stat;
485
+ zkrb_zoo_wexists_args_t args = {
486
+ .rc = ZKRB_FAIL,
487
+ .zh = zh,
488
+ .path = path,
489
+ .watcher = watcher,
490
+ .watcherCtx = watcherCtx,
491
+ .stat = stat
492
+ };
615
493
 
616
- zkrb_thread_blocking_region(zkrb_gvl_zoo_wexists, (void *)ptr);
494
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_wexists, (void *)&args);
617
495
 
618
- rc = ptr->rc;
619
-
620
- error:
621
- free(ptr);
622
- return rc;
496
+ return args.rc;
623
497
  }
624
498
 
625
499
 
@@ -631,25 +505,19 @@ static VALUE zkrb_gvl_zoo_get(void *data) {
631
505
 
632
506
  // wrapper that calls zoo_get via zkrb_gvl_zoo_get inside rb_thread_blocking_region
633
507
  int zkrb_call_zoo_get(zhandle_t *zh, const char *path, int watch, char *buffer, int* buffer_len, struct Stat *stat) {
634
- int rc = ZKRB_FAIL;
635
- zkrb_zoo_get_args_t *ptr = malloc(sizeof(zkrb_zoo_get_args_t));
636
- check_mem(ptr);
637
-
638
- ptr->rc = rc;
639
- ptr->zh = zh;
640
- ptr->path = path;
641
- ptr->watch = watch;
642
- ptr->buffer = buffer;
643
- ptr->buffer_len = buffer_len;
644
- ptr->stat = stat;
508
+ zkrb_zoo_get_args_t args = {
509
+ .rc = ZKRB_FAIL,
510
+ .zh = zh,
511
+ .path = path,
512
+ .watch = watch,
513
+ .buffer = buffer,
514
+ .buffer_len = buffer_len,
515
+ .stat = stat
516
+ };
645
517
 
646
- zkrb_thread_blocking_region(zkrb_gvl_zoo_get, (void *)ptr);
518
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_get, (void *)&args);
647
519
 
648
- rc = ptr->rc;
649
-
650
- error:
651
- free(ptr);
652
- return rc;
520
+ return args.rc;
653
521
  }
654
522
 
655
523
 
@@ -661,26 +529,20 @@ static VALUE zkrb_gvl_zoo_wget(void *data) {
661
529
 
662
530
  // wrapper that calls zoo_wget via zkrb_gvl_zoo_wget inside rb_thread_blocking_region
663
531
  int zkrb_call_zoo_wget(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, char *buffer, int* buffer_len, struct Stat *stat) {
664
- int rc = ZKRB_FAIL;
665
- zkrb_zoo_wget_args_t *ptr = malloc(sizeof(zkrb_zoo_wget_args_t));
666
- check_mem(ptr);
667
-
668
- ptr->rc = rc;
669
- ptr->zh = zh;
670
- ptr->path = path;
671
- ptr->watcher = watcher;
672
- ptr->watcherCtx = watcherCtx;
673
- ptr->buffer = buffer;
674
- ptr->buffer_len = buffer_len;
675
- ptr->stat = stat;
532
+ zkrb_zoo_wget_args_t args = {
533
+ .rc = ZKRB_FAIL,
534
+ .zh = zh,
535
+ .path = path,
536
+ .watcher = watcher,
537
+ .watcherCtx = watcherCtx,
538
+ .buffer = buffer,
539
+ .buffer_len = buffer_len,
540
+ .stat = stat
541
+ };
676
542
 
677
- zkrb_thread_blocking_region(zkrb_gvl_zoo_wget, (void *)ptr);
543
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_wget, (void *)&args);
678
544
 
679
- rc = ptr->rc;
680
-
681
- error:
682
- free(ptr);
683
- return rc;
545
+ return args.rc;
684
546
  }
685
547
 
686
548
 
@@ -692,24 +554,18 @@ static VALUE zkrb_gvl_zoo_set(void *data) {
692
554
 
693
555
  // wrapper that calls zoo_set via zkrb_gvl_zoo_set inside rb_thread_blocking_region
694
556
  int zkrb_call_zoo_set(zhandle_t *zh, const char *path, const char *buffer, int buflen, int version) {
695
- int rc = ZKRB_FAIL;
696
- zkrb_zoo_set_args_t *ptr = malloc(sizeof(zkrb_zoo_set_args_t));
697
- check_mem(ptr);
698
-
699
- ptr->rc = rc;
700
- ptr->zh = zh;
701
- ptr->path = path;
702
- ptr->buffer = buffer;
703
- ptr->buflen = buflen;
704
- ptr->version = version;
557
+ zkrb_zoo_set_args_t args = {
558
+ .rc = ZKRB_FAIL,
559
+ .zh = zh,
560
+ .path = path,
561
+ .buffer = buffer,
562
+ .buflen = buflen,
563
+ .version = version
564
+ };
705
565
 
706
- zkrb_thread_blocking_region(zkrb_gvl_zoo_set, (void *)ptr);
566
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_set, (void *)&args);
707
567
 
708
- rc = ptr->rc;
709
-
710
- error:
711
- free(ptr);
712
- return rc;
568
+ return args.rc;
713
569
  }
714
570
 
715
571
 
@@ -721,25 +577,19 @@ static VALUE zkrb_gvl_zoo_set2(void *data) {
721
577
 
722
578
  // wrapper that calls zoo_set2 via zkrb_gvl_zoo_set2 inside rb_thread_blocking_region
723
579
  int zkrb_call_zoo_set2(zhandle_t *zh, const char *path, const char *buffer, int buflen, int version, struct Stat *stat) {
724
- int rc = ZKRB_FAIL;
725
- zkrb_zoo_set2_args_t *ptr = malloc(sizeof(zkrb_zoo_set2_args_t));
726
- check_mem(ptr);
727
-
728
- ptr->rc = rc;
729
- ptr->zh = zh;
730
- ptr->path = path;
731
- ptr->buffer = buffer;
732
- ptr->buflen = buflen;
733
- ptr->version = version;
734
- ptr->stat = stat;
580
+ zkrb_zoo_set2_args_t args = {
581
+ .rc = ZKRB_FAIL,
582
+ .zh = zh,
583
+ .path = path,
584
+ .buffer = buffer,
585
+ .buflen = buflen,
586
+ .version = version,
587
+ .stat = stat
588
+ };
735
589
 
736
- zkrb_thread_blocking_region(zkrb_gvl_zoo_set2, (void *)ptr);
590
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_set2, (void *)&args);
737
591
 
738
- rc = ptr->rc;
739
-
740
- error:
741
- free(ptr);
742
- return rc;
592
+ return args.rc;
743
593
  }
744
594
 
745
595
 
@@ -751,23 +601,17 @@ static VALUE zkrb_gvl_zoo_get_children(void *data) {
751
601
 
752
602
  // wrapper that calls zoo_get_children via zkrb_gvl_zoo_get_children inside rb_thread_blocking_region
753
603
  int zkrb_call_zoo_get_children(zhandle_t *zh, const char *path, int watch, struct String_vector *strings) {
754
- int rc = ZKRB_FAIL;
755
- zkrb_zoo_get_children_args_t *ptr = malloc(sizeof(zkrb_zoo_get_children_args_t));
756
- check_mem(ptr);
757
-
758
- ptr->rc = rc;
759
- ptr->zh = zh;
760
- ptr->path = path;
761
- ptr->watch = watch;
762
- ptr->strings = strings;
604
+ zkrb_zoo_get_children_args_t args = {
605
+ .rc = ZKRB_FAIL,
606
+ .zh = zh,
607
+ .path = path,
608
+ .watch = watch,
609
+ .strings = strings
610
+ };
763
611
 
764
- zkrb_thread_blocking_region(zkrb_gvl_zoo_get_children, (void *)ptr);
612
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_get_children, (void *)&args);
765
613
 
766
- rc = ptr->rc;
767
-
768
- error:
769
- free(ptr);
770
- return rc;
614
+ return args.rc;
771
615
  }
772
616
 
773
617
 
@@ -779,24 +623,18 @@ static VALUE zkrb_gvl_zoo_wget_children(void *data) {
779
623
 
780
624
  // wrapper that calls zoo_wget_children via zkrb_gvl_zoo_wget_children inside rb_thread_blocking_region
781
625
  int zkrb_call_zoo_wget_children(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, struct String_vector *strings) {
782
- int rc = ZKRB_FAIL;
783
- zkrb_zoo_wget_children_args_t *ptr = malloc(sizeof(zkrb_zoo_wget_children_args_t));
784
- check_mem(ptr);
785
-
786
- ptr->rc = rc;
787
- ptr->zh = zh;
788
- ptr->path = path;
789
- ptr->watcher = watcher;
790
- ptr->watcherCtx = watcherCtx;
791
- ptr->strings = strings;
626
+ zkrb_zoo_wget_children_args_t args = {
627
+ .rc = ZKRB_FAIL,
628
+ .zh = zh,
629
+ .path = path,
630
+ .watcher = watcher,
631
+ .watcherCtx = watcherCtx,
632
+ .strings = strings
633
+ };
792
634
 
793
- zkrb_thread_blocking_region(zkrb_gvl_zoo_wget_children, (void *)ptr);
635
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_wget_children, (void *)&args);
794
636
 
795
- rc = ptr->rc;
796
-
797
- error:
798
- free(ptr);
799
- return rc;
637
+ return args.rc;
800
638
  }
801
639
 
802
640
 
@@ -808,24 +646,18 @@ static VALUE zkrb_gvl_zoo_get_children2(void *data) {
808
646
 
809
647
  // wrapper that calls zoo_get_children2 via zkrb_gvl_zoo_get_children2 inside rb_thread_blocking_region
810
648
  int zkrb_call_zoo_get_children2(zhandle_t *zh, const char *path, int watch, struct String_vector *strings, struct Stat *stat) {
811
- int rc = ZKRB_FAIL;
812
- zkrb_zoo_get_children2_args_t *ptr = malloc(sizeof(zkrb_zoo_get_children2_args_t));
813
- check_mem(ptr);
814
-
815
- ptr->rc = rc;
816
- ptr->zh = zh;
817
- ptr->path = path;
818
- ptr->watch = watch;
819
- ptr->strings = strings;
820
- ptr->stat = stat;
649
+ zkrb_zoo_get_children2_args_t args = {
650
+ .rc = ZKRB_FAIL,
651
+ .zh = zh,
652
+ .path = path,
653
+ .watch = watch,
654
+ .strings = strings,
655
+ .stat = stat
656
+ };
821
657
 
822
- zkrb_thread_blocking_region(zkrb_gvl_zoo_get_children2, (void *)ptr);
658
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_get_children2, (void *)&args);
823
659
 
824
- rc = ptr->rc;
825
-
826
- error:
827
- free(ptr);
828
- return rc;
660
+ return args.rc;
829
661
  }
830
662
 
831
663
 
@@ -837,25 +669,19 @@ static VALUE zkrb_gvl_zoo_wget_children2(void *data) {
837
669
 
838
670
  // wrapper that calls zoo_wget_children2 via zkrb_gvl_zoo_wget_children2 inside rb_thread_blocking_region
839
671
  int zkrb_call_zoo_wget_children2(zhandle_t *zh, const char *path, watcher_fn watcher, void* watcherCtx, struct String_vector *strings, struct Stat *stat) {
840
- int rc = ZKRB_FAIL;
841
- zkrb_zoo_wget_children2_args_t *ptr = malloc(sizeof(zkrb_zoo_wget_children2_args_t));
842
- check_mem(ptr);
843
-
844
- ptr->rc = rc;
845
- ptr->zh = zh;
846
- ptr->path = path;
847
- ptr->watcher = watcher;
848
- ptr->watcherCtx = watcherCtx;
849
- ptr->strings = strings;
850
- ptr->stat = stat;
672
+ zkrb_zoo_wget_children2_args_t args = {
673
+ .rc = ZKRB_FAIL,
674
+ .zh = zh,
675
+ .path = path,
676
+ .watcher = watcher,
677
+ .watcherCtx = watcherCtx,
678
+ .strings = strings,
679
+ .stat = stat
680
+ };
851
681
 
852
- zkrb_thread_blocking_region(zkrb_gvl_zoo_wget_children2, (void *)ptr);
682
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_wget_children2, (void *)&args);
853
683
 
854
- rc = ptr->rc;
855
-
856
- error:
857
- free(ptr);
858
- return rc;
684
+ return args.rc;
859
685
  }
860
686
 
861
687
 
@@ -867,23 +693,17 @@ static VALUE zkrb_gvl_zoo_get_acl(void *data) {
867
693
 
868
694
  // wrapper that calls zoo_get_acl via zkrb_gvl_zoo_get_acl inside rb_thread_blocking_region
869
695
  int zkrb_call_zoo_get_acl(zhandle_t *zh, const char *path, struct ACL_vector *acl, struct Stat *stat) {
870
- int rc = ZKRB_FAIL;
871
- zkrb_zoo_get_acl_args_t *ptr = malloc(sizeof(zkrb_zoo_get_acl_args_t));
872
- check_mem(ptr);
873
-
874
- ptr->rc = rc;
875
- ptr->zh = zh;
876
- ptr->path = path;
877
- ptr->acl = acl;
878
- ptr->stat = stat;
696
+ zkrb_zoo_get_acl_args_t args = {
697
+ .rc = ZKRB_FAIL,
698
+ .zh = zh,
699
+ .path = path,
700
+ .acl = acl,
701
+ .stat = stat
702
+ };
879
703
 
880
- zkrb_thread_blocking_region(zkrb_gvl_zoo_get_acl, (void *)ptr);
704
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_get_acl, (void *)&args);
881
705
 
882
- rc = ptr->rc;
883
-
884
- error:
885
- free(ptr);
886
- return rc;
706
+ return args.rc;
887
707
  }
888
708
 
889
709
 
@@ -895,23 +715,17 @@ static VALUE zkrb_gvl_zoo_set_acl(void *data) {
895
715
 
896
716
  // wrapper that calls zoo_set_acl via zkrb_gvl_zoo_set_acl inside rb_thread_blocking_region
897
717
  int zkrb_call_zoo_set_acl(zhandle_t *zh, const char *path, int version, const struct ACL_vector *acl) {
898
- int rc = ZKRB_FAIL;
899
- zkrb_zoo_set_acl_args_t *ptr = malloc(sizeof(zkrb_zoo_set_acl_args_t));
900
- check_mem(ptr);
901
-
902
- ptr->rc = rc;
903
- ptr->zh = zh;
904
- ptr->path = path;
905
- ptr->version = version;
906
- ptr->acl = acl;
907
-
908
- zkrb_thread_blocking_region(zkrb_gvl_zoo_set_acl, (void *)ptr);
718
+ zkrb_zoo_set_acl_args_t args = {
719
+ .rc = ZKRB_FAIL,
720
+ .zh = zh,
721
+ .path = path,
722
+ .version = version,
723
+ .acl = acl
724
+ };
909
725
 
910
- rc = ptr->rc;
726
+ zkrb_thread_blocking_region(zkrb_gvl_zoo_set_acl, (void *)&args);
911
727
 
912
- error:
913
- free(ptr);
914
- return rc;
728
+ return args.rc;
915
729
  }
916
730
 
917
731