dbm 1.0.0.beta1 → 1.0.0

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 +5 -5
  2. data/ext/dbm/dbm.c +33 -38
  3. metadata +5 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b16116b0c6e3aaba9c0c589f1a30b270b946ca4a
4
- data.tar.gz: c6d0f3eafb1421719c60b6c401aa7a864a372edf
2
+ SHA256:
3
+ metadata.gz: 0a41f0541a5b1ca11d6e5fd00833ba33e351eb902d20c8ec39e0c3014a349653
4
+ data.tar.gz: 554e59b084ca58459e020fcc72bc0f3a295500b1b9271eaa2875beb2d8bb6f78
5
5
  SHA512:
6
- metadata.gz: aa95f929e738fa54ebf06aba627e25fadb99ee6ddafcea9b034e2320bc20c73a7726ca95fa3bce4b3103a0b60f81626e46a81fdcd034f7cf664e5e478bc6071d
7
- data.tar.gz: b230660defee93cbbbd4627b48522305da5f589d830c23c7d1e3edb51ea9f1ede1a56a49002b7decbda6d4e24bd537eeb3e7702965669c125dfabde1177d88bb
6
+ metadata.gz: 875a4d5ff103150e3c76aae3598d0f29f7ec05f9d1daf88a7071d611f12aa2292073fa598737fbfd6e962156bffa469507654f1830cbd794ddf195b2620e62c5
7
+ data.tar.gz: 238be2641e4b18103f54cd5298b4bec0d4d334a4b33d75af9ce1079c7fc1dd6219b0045878f7dc2da85e59f872d8120255cedb2dbee620df437d9323c4bb4e49
@@ -24,7 +24,7 @@
24
24
  #define DSIZE_TYPE TYPEOF_DATUM_DSIZE
25
25
  #if SIZEOF_DATUM_DSIZE > SIZEOF_INT
26
26
  # define RSTRING_DSIZE(s) RSTRING_LEN(s)
27
- # define TOO_LONG(n) 0
27
+ # define TOO_LONG(n) ((void)(n),0)
28
28
  #else
29
29
  # define RSTRING_DSIZE(s) RSTRING_LENINT(s)
30
30
  # define TOO_LONG(n) ((long)(+(DSIZE_TYPE)(n)) != (n))
@@ -47,7 +47,6 @@ closed_dbm(void)
47
47
 
48
48
  #define GetDBM(obj, dbmp) do {\
49
49
  TypedData_Get_Struct((obj), struct dbmdata, &dbm_type, (dbmp));\
50
- if ((dbmp) == 0) closed_dbm();\
51
50
  if ((dbmp)->di_dbm == 0) closed_dbm();\
52
51
  } while (0)
53
52
 
@@ -60,21 +59,18 @@ static void
60
59
  free_dbm(void *ptr)
61
60
  {
62
61
  struct dbmdata *dbmp = ptr;
63
- if (dbmp) {
64
- if (dbmp->di_dbm) dbm_close(dbmp->di_dbm);
65
- xfree(dbmp);
66
- }
62
+ if (dbmp->di_dbm)
63
+ dbm_close(dbmp->di_dbm);
64
+ xfree(dbmp);
67
65
  }
68
66
 
69
67
  static size_t
70
68
  memsize_dbm(const void *ptr)
71
69
  {
72
- size_t size = 0;
73
70
  const struct dbmdata *dbmp = ptr;
74
- if (dbmp) {
75
- size += sizeof(*dbmp);
76
- if (dbmp->di_dbm) size += DBM_SIZEOF_DBM;
77
- }
71
+ size_t size = sizeof(*dbmp);
72
+ if (dbmp->di_dbm)
73
+ size += DBM_SIZEOF_DBM;
78
74
  return size;
79
75
  }
80
76
 
@@ -115,8 +111,6 @@ fdbm_closed(VALUE obj)
115
111
  struct dbmdata *dbmp;
116
112
 
117
113
  TypedData_Get_Struct(obj, struct dbmdata, &dbm_type, dbmp);
118
- if (dbmp == 0)
119
- return Qtrue;
120
114
  if (dbmp->di_dbm == 0)
121
115
  return Qtrue;
122
116
 
@@ -126,7 +120,9 @@ fdbm_closed(VALUE obj)
126
120
  static VALUE
127
121
  fdbm_alloc(VALUE klass)
128
122
  {
129
- return TypedData_Wrap_Struct(klass, &dbm_type, 0);
123
+ struct dbmdata *dbmp;
124
+
125
+ return TypedData_Make_Struct(klass, struct dbmdata, &dbm_type, dbmp);
130
126
  }
131
127
 
132
128
  /*
@@ -150,6 +146,7 @@ fdbm_initialize(int argc, VALUE *argv, VALUE obj)
150
146
  struct dbmdata *dbmp;
151
147
  int mode, flags = 0;
152
148
 
149
+ TypedData_Get_Struct(obj, struct dbmdata, &dbm_type, dbmp);
153
150
  if (rb_scan_args(argc, argv, "12", &file, &vmode, &vflags) == 1) {
154
151
  mode = 0666; /* default value */
155
152
  }
@@ -191,24 +188,24 @@ fdbm_initialize(int argc, VALUE *argv, VALUE obj)
191
188
  }
192
189
 
193
190
  if (dbm) {
194
- /*
195
- * History of dbm_pagfno() and dbm_dirfno() in ndbm and its compatibles.
196
- * (dbm_pagfno() and dbm_dirfno() is not standardized.)
197
- *
198
- * 1986: 4.3BSD provides ndbm.
199
- * It provides dbm_pagfno() and dbm_dirfno() as macros.
200
- * 1991: gdbm-1.5 provides them as functions.
201
- * They returns a same descriptor.
202
- * (Earlier releases may have the functions too.)
203
- * 1991: Net/2 provides Berkeley DB.
204
- * It doesn't provide dbm_pagfno() and dbm_dirfno().
205
- * 1992: 4.4BSD Alpha provides Berkeley DB with dbm_dirfno() as a function.
206
- * dbm_pagfno() is a macro as DBM_PAGFNO_NOT_AVAILABLE.
207
- * 1997: Berkeley DB 2.0 is released by Sleepycat Software, Inc.
208
- * It defines dbm_pagfno() and dbm_dirfno() as macros.
209
- * 2011: gdbm-1.9 creates a separate dir file.
210
- * dbm_pagfno() and dbm_dirfno() returns different descriptors.
211
- */
191
+ /*
192
+ * History of dbm_pagfno() and dbm_dirfno() in ndbm and its compatibles.
193
+ * (dbm_pagfno() and dbm_dirfno() is not standardized.)
194
+ *
195
+ * 1986: 4.3BSD provides ndbm.
196
+ * It provides dbm_pagfno() and dbm_dirfno() as macros.
197
+ * 1991: gdbm-1.5 provides them as functions.
198
+ * They returns a same descriptor.
199
+ * (Earlier releases may have the functions too.)
200
+ * 1991: Net/2 provides Berkeley DB.
201
+ * It doesn't provide dbm_pagfno() and dbm_dirfno().
202
+ * 1992: 4.4BSD Alpha provides Berkeley DB with dbm_dirfno() as a function.
203
+ * dbm_pagfno() is a macro as DBM_PAGFNO_NOT_AVAILABLE.
204
+ * 1997: Berkeley DB 2.0 is released by Sleepycat Software, Inc.
205
+ * It defines dbm_pagfno() and dbm_dirfno() as macros.
206
+ * 2011: gdbm-1.9 creates a separate dir file.
207
+ * dbm_pagfno() and dbm_dirfno() returns different descriptors.
208
+ */
212
209
  #if defined(HAVE_DBM_PAGFNO)
213
210
  rb_fd_fix_cloexec(dbm_pagfno(dbm));
214
211
  #endif
@@ -217,8 +214,8 @@ fdbm_initialize(int argc, VALUE *argv, VALUE obj)
217
214
  #endif
218
215
 
219
216
  #if defined(RUBYDBM_DB_HEADER) && defined(HAVE_TYPE_DBC)
220
- /* Disable Berkeley DB error messages such as:
221
- * DB->put: attempt to modify a read-only database */
217
+ /* Disable Berkeley DB error messages such as:
218
+ * DB->put: attempt to modify a read-only database */
222
219
  ((DBC*)dbm)->dbp->set_errfile(((DBC*)dbm)->dbp, NULL);
223
220
  #endif
224
221
  }
@@ -228,8 +225,8 @@ fdbm_initialize(int argc, VALUE *argv, VALUE obj)
228
225
  rb_sys_fail_str(file);
229
226
  }
230
227
 
231
- dbmp = ALLOC(struct dbmdata);
232
- DATA_PTR(obj) = dbmp;
228
+ if (dbmp->di_dbm)
229
+ dbm_close(dbmp->di_dbm);
233
230
  dbmp->di_dbm = dbm;
234
231
  dbmp->di_size = -1;
235
232
 
@@ -339,8 +336,6 @@ fdbm_key(VALUE obj, VALUE valstr)
339
336
  ExportStringValue(valstr);
340
337
  len = RSTRING_LEN(valstr);
341
338
  if (TOO_LONG(len)) return Qnil;
342
- val.dptr = RSTRING_PTR(valstr);
343
- val.dsize = (DSIZE_TYPE)len;
344
339
 
345
340
  GetDBM2(obj, dbmp, dbm);
346
341
  for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yukihiro Matsumoto
@@ -60,15 +60,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - ">="
62
62
  - !ruby/object:Gem::Version
63
- version: 2.5.0dev
63
+ version: 2.3.0
64
64
  required_rubygems_version: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 1.3.1
68
+ version: '0'
69
69
  requirements: []
70
70
  rubyforge_project:
71
- rubygems_version: 2.6.12
71
+ rubygems_version: 2.7.3
72
72
  signing_key:
73
73
  specification_version: 4
74
74
  summary: Provides a wrapper for the UNIX-style Database Manager Library