Ticket #325: Refactor-zlib-usage-in-FlintTable-and-ChertTable-to-avoid-reallocat.2.patch

File Refactor-zlib-usage-in-FlintTable-and-ChertTable-to-avoid-reallocat.2.patch, 18.9 KB (added by Richard Boulton, 15 years ago)

Improved patch

  • backends/chert/chert_table.h

     
    300300         *  Any outstanding changes (ie, changes made without commit() having
    301301         *  subsequently been called) will be lost.
    302302         */
    303         ~ChertTable();
     303        virtual ~ChertTable();
    304304
    305305        /** Close the Btree.  This closes and frees any of the btree
    306306         *  structures which have been created and opened.
     
    605605        /// The name of the table (used when writing changesets).
    606606        const char * tablename;
    607607
     608        void lazy_alloc_deflate_zstream() const;
     609        void lazy_alloc_inflate_zstream() const;
     610
    608611        /** revision number of the opened B-tree. */
    609612        chert_revision_number_t revision_number;
    610613
     
    723726         *  Z_RLE. */
    724727        int compress_strategy;
    725728
     729        /** Zlib state object */
     730        mutable z_stream *deflate_zstream;
     731        mutable z_stream *inflate_zstream;
     732
    726733        /// If true, don't create the table until it's needed.
    727734        bool lazy;
    728735
  • backends/chert/chert_table.cc

     
    10581058        CompileTimeAssert(DONT_COMPRESS != Z_RLE);
    10591059#endif
    10601060
    1061         z_stream stream;
     1061        lazy_alloc_deflate_zstream();
    10621062
    1063         stream.zalloc = reinterpret_cast<alloc_func>(0);
    1064         stream.zfree = reinterpret_cast<free_func>(0);
    1065         stream.opaque = (voidpf)0;
     1063        deflate_zstream->next_in = (Bytef *)const_cast<char *>(tag.data());
     1064        deflate_zstream->avail_in = (uInt)tag.size();
    10661065
    1067         // -15 means raw deflate with 32K LZ77 window (largest)
    1068         // memLevel 9 is the highest (8 is default)
    1069         int err;
    1070         err = deflateInit2(&stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -15, 9,
    1071                            compress_strategy);
    1072         if (err != Z_OK) {
    1073             if (err == Z_MEM_ERROR) throw std::bad_alloc();
    1074             string msg = "deflateInit2 failed";
    1075             if (stream.msg) {
    1076                 msg += " (";
    1077                 msg += stream.msg;
    1078                 msg += ')';
    1079             }
    1080             throw Xapian::DatabaseError(msg);
    1081         }
    1082 
    1083         stream.next_in = (Bytef *)const_cast<char *>(tag.data());
    1084         stream.avail_in = (uInt)tag.size();
    1085 
    10861066        // If compressed size is >= tag.size(), we don't want to compress.
    10871067        unsigned long blk_len = tag.size() - 1;
    10881068        unsigned char * blk = new unsigned char[blk_len];
    1089         stream.next_out = blk;
    1090         stream.avail_out = (uInt)blk_len;
     1069        deflate_zstream->next_out = blk;
     1070        deflate_zstream->avail_out = (uInt)blk_len;
    10911071
    1092         err = deflate(&stream, Z_FINISH);
     1072        int err = deflate(deflate_zstream, Z_FINISH);
    10931073        if (err == Z_STREAM_END) {
    10941074            // If deflate succeeded, then the output was at least one byte
    10951075            // smaller than the input.
    1096             tag.assign(reinterpret_cast<const char *>(blk), stream.total_out);
     1076            tag.assign(reinterpret_cast<const char *>(blk), deflate_zstream->total_out);
    10971077            compressed = true;
    1098             err = deflateEnd(&stream);
    1099             if (err != Z_OK) {
    1100                 string msg = "deflateEnd failed";
    1101                 if (stream.msg) {
    1102                     msg += " (";
    1103                     msg += stream.msg;
    1104                     msg += ')';
    1105                 }
    1106                 throw Xapian::DatabaseError(msg);
    1107             }
    1108         } else {
    1109             // Deflate failed - presumably the data wasn't compressible.
    1110             (void)deflateEnd(&stream);
    11111078        }
    11121079
    11131080        delete [] blk;
     
    12811248
    12821249    Bytef buf[8192];
    12831250
    1284     z_stream stream;
    1285     stream.next_out = buf;
    1286     stream.avail_out = (uInt)sizeof(buf);
     1251    lazy_alloc_inflate_zstream();
    12871252
    1288     stream.zalloc = reinterpret_cast<alloc_func>(0);
    1289     stream.zfree = reinterpret_cast<free_func>(0);
     1253    inflate_zstream->next_out = buf;
     1254    inflate_zstream->avail_out = (uInt)sizeof(buf);
    12901255
    1291     stream.next_in = Z_NULL;
    1292     stream.avail_in = 0;
     1256    inflate_zstream->next_in = (Bytef*)const_cast<char *>(tag->data());
     1257    inflate_zstream->avail_in = (uInt)tag->size();
    12931258
    1294     int err = inflateInit2(&stream, -15);
    1295     if (err != Z_OK) {
    1296         if (err == Z_MEM_ERROR) throw std::bad_alloc();
    1297         string msg = "inflateInit2 failed";
    1298         if (stream.msg) {
    1299             msg += " (";
    1300             msg += stream.msg;
    1301             msg += ')';
    1302         }
    1303         throw Xapian::DatabaseError(msg);
    1304     }
    1305 
    1306     stream.next_in = (Bytef*)const_cast<char *>(tag->data());
    1307     stream.avail_in = (uInt)tag->size();
    1308 
     1259    int err = Z_OK;
    13091260    while (err != Z_STREAM_END) {
    1310         stream.next_out = buf;
    1311         stream.avail_out = (uInt)sizeof(buf);
    1312         err = inflate(&stream, Z_SYNC_FLUSH);
    1313         if (err == Z_BUF_ERROR && stream.avail_in == 0) {
    1314             LOGLINE(DB, "Z_BUF_ERROR - faking checksum of " << stream.adler);
     1261        inflate_zstream->next_out = buf;
     1262        inflate_zstream->avail_out = (uInt)sizeof(buf);
     1263        err = inflate(inflate_zstream, Z_SYNC_FLUSH);
     1264        if (err == Z_BUF_ERROR && inflate_zstream->avail_in == 0) {
     1265            LOGLINE(DB, "Z_BUF_ERROR - faking checksum of " << inflate_zstream->adler);
    13151266            Bytef header2[4];
    1316             setint4(header2, 0, stream.adler);
    1317             stream.next_in = header2;
    1318             stream.avail_in = 4;
    1319             err = inflate(&stream, Z_SYNC_FLUSH);
     1267            setint4(header2, 0, inflate_zstream->adler);
     1268            inflate_zstream->next_in = header2;
     1269            inflate_zstream->avail_in = 4;
     1270            err = inflate(inflate_zstream, Z_SYNC_FLUSH);
    13201271            if (err == Z_STREAM_END) break;
    13211272        }
    13221273
    13231274        if (err != Z_OK && err != Z_STREAM_END) {
    13241275            if (err == Z_MEM_ERROR) throw std::bad_alloc();
    13251276            string msg = "inflate failed";
    1326             if (stream.msg) {
     1277            if (inflate_zstream->msg) {
    13271278                msg += " (";
    1328                 msg += stream.msg;
     1279                msg += inflate_zstream->msg;
    13291280                msg += ')';
    13301281            }
    13311282            throw Xapian::DatabaseError(msg);
    13321283        }
    13331284
    13341285        utag.append(reinterpret_cast<const char *>(buf),
    1335                     stream.next_out - buf);
     1286                    inflate_zstream->next_out - buf);
    13361287    }
    1337     if (utag.size() != stream.total_out) {
     1288    if (utag.size() != inflate_zstream->total_out) {
    13381289        string msg = "compressed tag didn't expand to the expected size: ";
    13391290        msg += om_tostring(utag.size());
    13401291        msg += " != ";
    13411292        // OpenBSD's zlib.h uses off_t instead of uLong for total_out.
    1342         msg += om_tostring((size_t)stream.total_out);
     1293        msg += om_tostring((size_t)inflate_zstream->total_out);
    13431294        throw Xapian::DatabaseCorruptError(msg);
    13441295    }
    13451296
    1346     err = inflateEnd(&stream);
    1347     if (err != Z_OK) abort();
    1348 
    13491297    swap(*tag, utag);
    13501298
    13511299    RETURN(false);
     
    16331581          writable(!readonly_),
    16341582          split_p(0),
    16351583          compress_strategy(compress_strategy_),
     1584          deflate_zstream(NULL),
     1585          inflate_zstream(NULL),
    16361586          lazy(lazy_)
    16371587{
    16381588    LOGCALL_CTOR(DB, "ChertTable",
    16391589                 tablename_ << "," << path_ << ", " << readonly_ << ", " <<
    16401590                 compress_strategy_ << ", " << lazy_);
     1591
     1592    // We want to do this lazily, but the read functions are const so we can't :(
     1593    lazy_alloc_inflate_zstream();
     1594
    16411595}
    16421596
     1597void
     1598ChertTable::lazy_alloc_deflate_zstream() const {
     1599    if (deflate_zstream) {
     1600        deflateReset(deflate_zstream);
     1601        return;
     1602    }
     1603
     1604    deflate_zstream = new z_stream;
     1605
     1606    deflate_zstream->zalloc = reinterpret_cast<alloc_func>(0);
     1607    deflate_zstream->zfree = reinterpret_cast<free_func>(0);
     1608    deflate_zstream->opaque = (voidpf)0;
     1609
     1610    // -15 means raw deflate with 32K LZ77 window (largest)
     1611    // memLevel 9 is the highest (8 is default)
     1612    int err;
     1613    err = deflateInit2(deflate_zstream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -15, 9,
     1614                       compress_strategy);
     1615    if (err != Z_OK) {
     1616        if (err == Z_MEM_ERROR) throw std::bad_alloc();
     1617        string msg = "deflateInit2 failed. err = " + err;
     1618        if (deflate_zstream->msg) {
     1619            msg += " (";
     1620            msg += deflate_zstream->msg;
     1621            msg += ')';
     1622        }
     1623        throw Xapian::DatabaseError(msg);
     1624    }
     1625}
     1626
     1627void
     1628ChertTable::lazy_alloc_inflate_zstream() const {
     1629    if (inflate_zstream) {
     1630        inflateReset(inflate_zstream);
     1631        return;
     1632    }
     1633
     1634    inflate_zstream = new z_stream;
     1635
     1636    inflate_zstream->zalloc = reinterpret_cast<alloc_func>(0);
     1637    inflate_zstream->zfree = reinterpret_cast<free_func>(0);
     1638
     1639    inflate_zstream->next_in = Z_NULL;
     1640    inflate_zstream->avail_in = 0;
     1641
     1642    int err = inflateInit2(inflate_zstream, -15);
     1643    if (err != Z_OK) {
     1644        if (err == Z_MEM_ERROR) throw std::bad_alloc();
     1645        string msg = "inflateInit2 failed";
     1646        if (inflate_zstream->msg) {
     1647            msg += " (";
     1648            msg += inflate_zstream->msg;
     1649            msg += ')';
     1650        }
     1651        throw Xapian::DatabaseError(msg);
     1652    }
     1653}
     1654
    16431655bool
    16441656ChertTable::exists() const {
    16451657    LOGCALL(DB, bool, "ChertTable::exists", "");
     
    17241736ChertTable::~ChertTable() {
    17251737    LOGCALL_DTOR(DB, "ChertTable");
    17261738    ChertTable::close();
     1739
     1740    if (deflate_zstream) {
     1741        int err = deflateEnd(deflate_zstream);
     1742        if (err != Z_OK) {
     1743            // FIXME - display the warning message somewhere.
     1744            //string msg = "deflateEnd failed. err = " + err;
     1745            //if (deflate_zstream->msg) {
     1746            //    msg += " (";
     1747            //    msg += deflate_zstream->msg;
     1748            //    msg += ')';
     1749            //}
     1750            //
     1751            // Note - we mustn't throw an exception because we're in a
     1752            // destructor.  If the destructor was called due to stack
     1753            // unwinding for another exception, this will result in a
     1754            // call to terminate().
     1755        }
     1756        delete deflate_zstream;
     1757    }
     1758
     1759    if (inflate_zstream) {
     1760        int err = inflateEnd(inflate_zstream);
     1761        if (err != Z_OK) {
     1762            // FIXME - display the warning message somewhere.
     1763            //string msg = "inflateEnd failed. err = " + err;
     1764            //if (inflate_zstream->msg) {
     1765            //    msg += " (";
     1766            //    msg += inflate_zstream->msg;
     1767            //    msg += ')';
     1768            //}
     1769            //
     1770            // Note - we mustn't throw an exception because we're in a
     1771            // destructor.  If the destructor was called due to stack
     1772            // unwinding for another exception, this will result in a
     1773            // call to terminate().
     1774        }
     1775        delete inflate_zstream;
     1776    }
    17271777}
    17281778
    17291779void ChertTable::close(bool permanent) {
  • backends/flint/flint_table.cc

     
    10381038        CompileTimeAssert(DONT_COMPRESS != Z_RLE);
    10391039#endif
    10401040
    1041         z_stream stream;
     1041        lazy_alloc_deflate_zstream();
    10421042
    1043         stream.zalloc = reinterpret_cast<alloc_func>(0);
    1044         stream.zfree = reinterpret_cast<free_func>(0);
    1045         stream.opaque = (voidpf)0;
     1043        deflate_zstream->next_in = (Bytef *)const_cast<char *>(tag.data());
     1044        deflate_zstream->avail_in = (uInt)tag.size();
    10461045
    1047         // -15 means raw deflate with 32K LZ77 window (largest)
    1048         // memLevel 9 is the highest (8 is default)
    1049         int err;
    1050         err = deflateInit2(&stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -15, 9,
    1051                            compress_strategy);
    1052         if (err != Z_OK) {
    1053             if (err == Z_MEM_ERROR) throw std::bad_alloc();
    1054             string msg = "deflateInit2 failed";
    1055             if (stream.msg) {
    1056                 msg += " (";
    1057                 msg += stream.msg;
    1058                 msg += ')';
    1059             }
    1060             throw Xapian::DatabaseError(msg);
    1061         }
    1062 
    1063         stream.next_in = (Bytef *)const_cast<char *>(tag.data());
    1064         stream.avail_in = (uInt)tag.size();
    1065 
    10661046        // If compressed size is >= tag.size(), we don't want to compress.
    10671047        unsigned long blk_len = tag.size() - 1;
    10681048        unsigned char * blk = new unsigned char[blk_len];
    1069         stream.next_out = blk;
    1070         stream.avail_out = (uInt)blk_len;
     1049        deflate_zstream->next_out = blk;
     1050        deflate_zstream->avail_out = (uInt)blk_len;
    10711051
    1072         err = deflate(&stream, Z_FINISH);
     1052        int err = deflate(deflate_zstream, Z_FINISH);
    10731053        if (err == Z_STREAM_END) {
    10741054            // If deflate succeeded, then the output was at least one byte
    10751055            // smaller than the input.
    1076             tag.assign(reinterpret_cast<const char *>(blk), stream.total_out);
     1056            tag.assign(reinterpret_cast<const char *>(blk), deflate_zstream->total_out);
    10771057            compressed = true;
    1078             err = deflateEnd(&stream);
    1079             if (err != Z_OK) {
    1080                 string msg = "deflateEnd failed";
    1081                 if (stream.msg) {
    1082                     msg += " (";
    1083                     msg += stream.msg;
    1084                     msg += ')';
    1085                 }
    1086                 throw Xapian::DatabaseError(msg);
    1087             }
    1088         } else {
    1089             // Deflate failed - presumably the data wasn't compressible.
    1090             (void)deflateEnd(&stream);
    10911058        }
    10921059
    10931060        delete [] blk;
     
    12601227
    12611228    Bytef buf[8192];
    12621229
    1263     z_stream stream;
    1264     stream.next_out = buf;
    1265     stream.avail_out = (uInt)sizeof(buf);
     1230    lazy_alloc_inflate_zstream();
    12661231
    1267     stream.zalloc = reinterpret_cast<alloc_func>(0);
    1268     stream.zfree = reinterpret_cast<free_func>(0);
     1232    inflate_zstream->next_out = buf;
     1233    inflate_zstream->avail_out = (uInt)sizeof(buf);
    12691234
    1270     stream.next_in = Z_NULL;
    1271     stream.avail_in = 0;
     1235    inflate_zstream->next_in = (Bytef*)const_cast<char *>(tag->data());
     1236    inflate_zstream->avail_in = (uInt)tag->size();
    12721237
    1273     int err = inflateInit2(&stream, -15);
    1274     if (err != Z_OK) {
    1275         if (err == Z_MEM_ERROR) throw std::bad_alloc();
    1276         string msg = "inflateInit2 failed";
    1277         if (stream.msg) {
    1278             msg += " (";
    1279             msg += stream.msg;
    1280             msg += ')';
    1281         }
    1282         throw Xapian::DatabaseError(msg);
    1283     }
    1284 
    1285     stream.next_in = (Bytef*)const_cast<char *>(tag->data());
    1286     stream.avail_in = (uInt)tag->size();
    1287 
     1238    int err = Z_OK;
    12881239    while (err != Z_STREAM_END) {
    1289         stream.next_out = buf;
    1290         stream.avail_out = (uInt)sizeof(buf);
    1291         err = inflate(&stream, Z_SYNC_FLUSH);
    1292         if (err == Z_BUF_ERROR && stream.avail_in == 0) {
    1293             LOGLINE(DB, "Z_BUF_ERROR - faking checksum of " << stream.adler);
     1240        inflate_zstream->next_out = buf;
     1241        inflate_zstream->avail_out = (uInt)sizeof(buf);
     1242        err = inflate(inflate_zstream, Z_SYNC_FLUSH);
     1243        if (err == Z_BUF_ERROR && inflate_zstream->avail_in == 0) {
     1244            LOGLINE(DB, "Z_BUF_ERROR - faking checksum of " << inflate_zstream->adler);
    12941245            Bytef header2[4];
    1295             setint4(header2, 0, stream.adler);
    1296             stream.next_in = header2;
    1297             stream.avail_in = 4;
    1298             err = inflate(&stream, Z_SYNC_FLUSH);
     1246            setint4(header2, 0, inflate_zstream->adler);
     1247            inflate_zstream->next_in = header2;
     1248            inflate_zstream->avail_in = 4;
     1249            err = inflate(inflate_zstream, Z_SYNC_FLUSH);
    12991250            if (err == Z_STREAM_END) break;
    13001251        }
    13011252
    13021253        if (err != Z_OK && err != Z_STREAM_END) {
    13031254            if (err == Z_MEM_ERROR) throw std::bad_alloc();
    13041255            string msg = "inflate failed";
    1305             if (stream.msg) {
     1256            if (inflate_zstream->msg) {
    13061257                msg += " (";
    1307                 msg += stream.msg;
     1258                msg += inflate_zstream->msg;
    13081259                msg += ')';
    13091260            }
    13101261            throw Xapian::DatabaseError(msg);
    13111262        }
    13121263
    13131264        utag.append(reinterpret_cast<const char *>(buf),
    1314                     stream.next_out - buf);
     1265                    inflate_zstream->next_out - buf);
    13151266    }
    1316     if (utag.size() != stream.total_out) {
     1267    if (utag.size() != inflate_zstream->total_out) {
    13171268        string msg = "compressed tag didn't expand to the expected size: ";
    13181269        msg += om_tostring(utag.size());
    13191270        msg += " != ";
    13201271        // OpenBSD's zlib.h uses off_t instead of uLong for total_out.
    1321         msg += om_tostring((size_t)stream.total_out);
     1272        msg += om_tostring((size_t)inflate_zstream->total_out);
    13221273        throw Xapian::DatabaseCorruptError(msg);
    13231274    }
    13241275
    1325     err = inflateEnd(&stream);
    1326     if (err != Z_OK) abort();
    1327 
    13281276    swap(*tag, utag);
    13291277
    13301278    return false;
     
    16071555          writable(!readonly_),
    16081556          split_p(0),
    16091557          compress_strategy(compress_strategy_),
     1558          deflate_zstream(NULL),
     1559          inflate_zstream(NULL),
    16101560          lazy(lazy_)
    16111561{
    1612     DEBUGCALL(DB, void, "FlintTable::FlintTable", 
     1562    DEBUGCALL(DB, void, "FlintTable::FlintTable",
    16131563              tablename_ << "," << path_ << ", " << readonly_ << ", " <<
    16141564              compress_strategy_ << ", " << lazy_);
     1565
     1566    // We want to do this lazily, but the read functions are const so we can't :(
     1567    lazy_alloc_inflate_zstream();
     1568
    16151569}
    16161570
     1571void
     1572FlintTable::lazy_alloc_deflate_zstream() const {
     1573    if (deflate_zstream) {
     1574        deflateReset(deflate_zstream);
     1575        return;
     1576    }
     1577
     1578    deflate_zstream = new z_stream;
     1579
     1580    deflate_zstream->zalloc = reinterpret_cast<alloc_func>(0);
     1581    deflate_zstream->zfree = reinterpret_cast<free_func>(0);
     1582    deflate_zstream->opaque = (voidpf)0;
     1583
     1584    // -15 means raw deflate with 32K LZ77 window (largest)
     1585    // memLevel 9 is the highest (8 is default)
     1586    int err;
     1587    err = deflateInit2(deflate_zstream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -15, 9,
     1588                       compress_strategy);
     1589    if (err != Z_OK) {
     1590        if (err == Z_MEM_ERROR) throw std::bad_alloc();
     1591        string msg = "deflateInit2 failed. err = " + err;
     1592        if (deflate_zstream->msg) {
     1593            msg += " (";
     1594            msg += deflate_zstream->msg;
     1595            msg += ')';
     1596        }
     1597        throw Xapian::DatabaseError(msg);
     1598    }
     1599}
     1600
     1601void
     1602FlintTable::lazy_alloc_inflate_zstream() const {
     1603    if (inflate_zstream) {
     1604        inflateReset(inflate_zstream);
     1605        return;
     1606    }
     1607
     1608    inflate_zstream = new z_stream;
     1609
     1610    inflate_zstream->zalloc = reinterpret_cast<alloc_func>(0);
     1611    inflate_zstream->zfree = reinterpret_cast<free_func>(0);
     1612
     1613    inflate_zstream->next_in = Z_NULL;
     1614    inflate_zstream->avail_in = 0;
     1615
     1616    int err = inflateInit2(inflate_zstream, -15);
     1617    if (err != Z_OK) {
     1618        if (err == Z_MEM_ERROR) throw std::bad_alloc();
     1619        string msg = "inflateInit2 failed";
     1620        if (inflate_zstream->msg) {
     1621            msg += " (";
     1622            msg += inflate_zstream->msg;
     1623            msg += ')';
     1624        }
     1625        throw Xapian::DatabaseError(msg);
     1626    }
     1627}
     1628
    16171629bool
    16181630FlintTable::exists() const {
    16191631    DEBUGCALL(DB, bool, "FlintTable::exists", "");
     
    16981710FlintTable::~FlintTable() {
    16991711    DEBUGCALL(DB, void, "FlintTable::~FlintTable", "");
    17001712    FlintTable::close();
     1713
     1714    if (deflate_zstream) {
     1715        int err = deflateEnd(deflate_zstream);
     1716        if (err != Z_OK) {
     1717            // FIXME - display the warning message somewhere.
     1718            //string msg = "deflateEnd failed. err = " + err;
     1719            //if (deflate_zstream->msg) {
     1720            //    msg += " (";
     1721            //    msg += deflate_zstream->msg;
     1722            //    msg += ')';
     1723            //}
     1724            //
     1725            // Note - we mustn't throw an exception because we're in a
     1726            // destructor.  If the destructor was called due to stack
     1727            // unwinding for another exception, this will result in a
     1728            // call to terminate().
     1729        }
     1730        delete deflate_zstream;
     1731    }
     1732
     1733    if (inflate_zstream) {
     1734        int err = inflateEnd(inflate_zstream);
     1735        if (err != Z_OK) {
     1736            // FIXME - display the warning message somewhere.
     1737            //string msg = "inflateEnd failed. err = " + err;
     1738            //if (inflate_zstream->msg) {
     1739            //    msg += " (";
     1740            //    msg += inflate_zstream->msg;
     1741            //    msg += ')';
     1742            //}
     1743            //
     1744            // Note - we mustn't throw an exception because we're in a
     1745            // destructor.  If the destructor was called due to stack
     1746            // unwinding for another exception, this will result in a
     1747            // call to terminate().
     1748        }
     1749        delete inflate_zstream;
     1750    }
    17011751}
    17021752
    17031753void FlintTable::close(bool permanent) {
  • backends/flint/flint_table.h

     
    290290         *  Any outstanding changes (ie, changes made without commit() having
    291291         *  subsequently been called) will be lost.
    292292         */
    293         ~FlintTable();
     293        virtual ~FlintTable();
    294294
    295295        /** Close the Btree.  This closes and frees any of the btree
    296296         *  structures which have been created and opened.
     
    595595           return (base_letter == 'A') ? 'B' : 'A';
    596596        }
    597597
     598        void lazy_alloc_deflate_zstream() const;
     599        void lazy_alloc_inflate_zstream() const;
     600
    598601        /** revision number of the opened B-tree. */
    599602        flint_revision_number_t revision_number;
    600603
     
    713716         *  Z_RLE. */
    714717        int compress_strategy;
    715718
     719        /** Zlib state object */
     720        mutable z_stream *deflate_zstream;
     721        mutable z_stream *inflate_zstream;
     722
    716723        /// If true, don't create the table until it's needed.
    717724        bool lazy;
    718725