Permalink
Browse files

import CDB_File 0.91 from CPAN

git-cpan-module:   CDB_File
git-cpan-version:  0.91
git-cpan-authorid: TIMPX
git-cpan-file:     authors/id/T/TI/TIMPX/CDB_File-0.91.tar.gz
  • Loading branch information...
1 parent 97321f6 commit f69c396653619551416b090095aad9fbefcb0251 Tim Goodwin committed with schwern Dec 18, 2001
Showing with 33 additions and 14 deletions.
  1. +2 −1 ACKNOWLEDGE
  2. +11 −5 CDB_File.pm
  3. +6 −2 CDB_File.xs
  4. +5 −0 CHANGES
  5. +2 −2 INSTALL
  6. +6 −3 README
  7. +1 −1 test.pl
View
@@ -13,6 +13,7 @@ The help of these people is gratefully acknowledged.
JH John Horne <J.Horne@plymouth.ac.uk>
JPB Joao Bordalo <jpb@ip.pt>
MdlR Michael de la Rue <mikedlr@tardis.ed.ac.uk>
+ MJP M J Pomraning <mjp@pilcrow.madison.wi.us>
MP Mark Powell <mark@salford.ac.uk>
NMS Nickolay Saukh <nms@nns.ru>
RDM Raul Miller <rdm@test.legislate.com>
@@ -21,4 +22,4 @@ The help of these people is gratefully acknowledged.
Tim Goodwin
<tjg@star.le.ac.uk>
-2001-05-25
+2001-12-18
View
@@ -10,7 +10,7 @@ use Exporter ();
@ISA = qw(Exporter DynaLoader);
@EXPORT_OK = qw(create);
-$VERSION = '0.86';
+$VERSION = '0.91';
=head1 NAME
@@ -250,6 +250,15 @@ prints B<gato chat>.
print "@{$catref->multi_get('cat')}";
+C<multi_get> always returns an array reference. If the key was not
+found in the database, it will be a reference to an empty array. To
+test whether the key was found, you must test the array, and not the
+reference.
+
+ $x = $catref->multiget($key);
+ warn "$key not found\n" unless $x; # WRONG; message never printed
+ warn "$key not found\n" unless @$x; # Correct
+
=head1 RETURN VALUES
The routines C<tie>, C<new>, and C<finish> return B<undef> if the
@@ -285,10 +294,7 @@ why you'd want to do this), you need to call FIRSTKEY first.
=head1 BUGS
-It ain't lightweight after you've plumbed Perl into it.
-
-The Perl interface to B<cdb> imposes the restriction that data must fit
-into memory.
+The C<create()> inteface could be done with C<TIEHASH>.
=head1 SEE ALSO
View
@@ -713,7 +713,7 @@ cdb_finish(cdbmake)
struct cdb_make *this;
U32 len, u;
U32 count, memsize, where;
- struct cdb_hplist *x;
+ struct cdb_hplist *x, *prev;
struct cdb_hp *hp;
this = (struct cdb_make *)SvPV(SvRV(cdbmake), PL_na);
@@ -725,7 +725,7 @@ cdb_finish(cdbmake)
i = x->num;
while (i--)
++this->count[255 & x->hp[i].h];
- }
+ }
memsize = 1;
for (i = 0; i < 256; ++i) {
@@ -749,11 +749,15 @@ cdb_finish(cdbmake)
this->start[i] = u;
}
+ prev = 0;
for (x = this->head; x; x = x->next) {
i = x->num;
while (i--)
this->split[--this->start[255 & x->hp[i].h]] = x->hp[i];
+ if (prev) Safefree(prev);
+ prev = x;
}
+ if (prev) Safefree(prev);
for (i = 0; i < 256; ++i) {
count = this->count[i];
View
@@ -1,5 +1,10 @@
Revision history for Perl extension CDB_File.
+0.91 2001-12-18
+ - fix memory leak (thanks MJP)
+ - document and test that multi_get returns ref to empty hash
+ - beta release
+
0.86 2001-05-25
- add handle, datalen, and datapos methods for low level access
- simplify multi_get, and remove a memory leak
View
@@ -12,7 +12,7 @@ You need Perl 5.005 or later.
make test
-You should see `ok 1' through to `ok 37'.
+You should see `ok 1' through to `ok 38'.
If any tests fail, please get in touch so we can sort out the problem.
@@ -31,4 +31,4 @@ enhancements, please contact me.
Tim Goodwin
<tjg@star.le.ac.uk>
-2001-02-06
+2001-05-29
View
9 README
@@ -1,5 +1,8 @@
-This is beta prerelease 0.86 of CDB_File. See INSTALL for installation
-instructions.
+This is beta release 0.91 of CDB_File.
+
+This release fixes a memory leak.
+
+See INSTALL for installation instructions.
CDB_File is a module which provides a Perl interface to Dan Berstein's
cdb package:
@@ -11,4 +14,4 @@ cdb package:
Tim Goodwin
<tjg@star.le.ac.uk>
-2001-05-25
+2001-12-18
View
@@ -147,7 +147,7 @@
print "ok 27\n";
$v = $t->multi_get('foo');
-@$v and print 'not ';
+ref $v eq 'ARRAY' and not @$v or print 'not ';
print "ok 28\n";
while (($k, $v) = each %h) {

0 comments on commit f69c396

Please sign in to comment.