mmdb 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/ext/mmdb/mmdb.c +5 -4
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad529fdf8ed88f374d68a50945c7d35545e5e951
4
- data.tar.gz: 1df94fc12ba9eb92b999e2fa0944dbcdeae89072
3
+ metadata.gz: 7e5f7bbfaa5e24e81cfd768fa0832cabc759e253
4
+ data.tar.gz: d016b0ec38b2ac3fca4d8fae2f19eebf1f81fa52
5
5
  SHA512:
6
- metadata.gz: 3d3bd638e59a2c155bb00cbb320a9bc909f0543441a74504b5d667fec5d96e7bd38da9caed2caac2d356960bcbcf6afe70e2e255150025dd857b15310abff377
7
- data.tar.gz: e85ff600fb171883011c9ce26821f2c0c68cbf29d9563aee1d92b9d1016fca359e725416f9a7d95bc3a6e5831a328a0fb9cb54b461b69279146e593773c6b92b
6
+ metadata.gz: 9dff7fdc715b8e670a316da3e790f705b027d54bbd483e333f240dbe547da799e325cb803369eaefedc22d26a56b948d250f6fb104509ca0a5f9286aeb32daed
7
+ data.tar.gz: 8657a8313b32767fd274cb02fdf2919a2b1882abc41c30a98e5d966e9a63f891d2c1e5c2484a0e744d95f1dca51e92d47c92d33d15764c35d684270edccfc890
data/ext/mmdb/mmdb.c CHANGED
@@ -52,6 +52,7 @@ maxminddb_memsize(const void *p) {
52
52
  void
53
53
  maxminddb_free(void *p) {
54
54
  struct MaxMindDB *ptr = p;
55
+
55
56
  if (ptr) {
56
57
  if (ptr->mmdb) {
57
58
  MMDB_close(ptr->mmdb);
@@ -72,9 +73,11 @@ static const rb_data_type_t mmdb_data_type = {
72
73
  static struct MaxMindDB*
73
74
  get_maxminddb(VALUE self) {
74
75
  struct MaxMindDB *ptr = check_maxminddb(self);
76
+
75
77
  if (!ptr) {
76
78
  rb_raise(rb_eStandardError, "uninitialized");
77
79
  }
80
+
78
81
  return ptr;
79
82
  }
80
83
 
@@ -134,7 +137,6 @@ maxminddb_initialize(int argc, VALUE* argv, VALUE self) {
134
137
  VALUE
135
138
  maxminddb_lookup(VALUE self, VALUE ip) {
136
139
  VALUE ret;
137
- char *target;
138
140
  int gai_error, mmdb_error;
139
141
  struct MaxMindDB *ptr = MaxMindDB(self);
140
142
  MMDB_s *mmdb = ptr->mmdb;
@@ -143,9 +145,7 @@ maxminddb_lookup(VALUE self, VALUE ip) {
143
145
  return Qnil;
144
146
  }
145
147
 
146
- target = StringValuePtr(ip);
147
-
148
- MMDB_lookup_result_s lookuped = MMDB_lookup_string(mmdb, target, &gai_error, &mmdb_error);
148
+ MMDB_lookup_result_s lookuped = MMDB_lookup_string(mmdb, StringValuePtr(ip), &gai_error, &mmdb_error);
149
149
  if (gai_error) {
150
150
  rb_sys_fail(gai_strerror(gai_error));
151
151
  }
@@ -185,6 +185,7 @@ maxminddb_close(VALUE self) {
185
185
  if (ptr) {
186
186
  if (ptr->mmdb) {
187
187
  MMDB_close(ptr->mmdb);
188
+ ptr->mmdb = NULL;
188
189
  }
189
190
  }
190
191
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mmdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - yoppi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-03 00:00:00.000000000 Z
11
+ date: 2016-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler