int DocumentDatabase::getContent(Transaction *txn, DbtOut &key, DbtOut &data, u_int32_t flags) const { int err = 0; // NOTE: db_.get() does not throw on DB_NOTFOUND, but // try/catch anyway... err = content_.get(txn, &key, &data, flags); if(err == 0 && (data.size != 0)) { if (compressor_) { XmlData source(data.data, data.size); XmlData dest; XmlTransaction xtxn(txn); if(!compressor_->decompress(xtxn, source, dest)){ throw XmlException(XmlException::INTERNAL_ERROR, "Error while tring to decompress your XML document."); } /* Replace the buffer in data with the one in dest. Because of this, DbtOut and Buffer must both use malloc and free*/ if (data.data != dest.get_data()) data.setNoCopy((*dest.getBuffer())->donateBuffer(), dest.get_size()); } } return err; }