[Xapian-tickets] [Xapian] #325: flint_table.cc uses zlib inefficiently

Xapian nobody at xapian.org
Tue Mar 3 15:12:29 GMT 2009


#325: flint_table.cc uses zlib inefficiently
---------------------------+------------------------------------------------
 Reporter:  tlipcon        |        Owner:  richard  
     Type:  enhancement    |       Status:  reopened 
 Priority:  normal         |    Milestone:  1.1.0    
Component:  Backend-Flint  |      Version:  SVN trunk
 Severity:  normal         |   Resolution:           
 Keywords:                 |    Blockedby:           
 Platform:  All            |     Blocking:           
---------------------------+------------------------------------------------

Comment(by richard):

 Looking at the code in zlib1g for inflateReset() and deflateReset(), they
 currently only return errors if given an invalid stream.  For
 inflateReset():

 {{{
     if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
 }}}

 For deflateReset():

 {{{
     if (strm == Z_NULL || strm->state == Z_NULL ||
         strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) {
         return Z_STREAM_ERROR;
     }
 }}}

 This is only going to happen if a previous error occurred, or we failed to
 call the initialisation code somehow, so I think just raising an exception
 is perfectly reasonable here.

 Looking at the code for inflateInit2() and deflateInit2 - they seem to
 carefully ensure that they clean up the structure on error, so all we
 should need to do is delete the zstream (which happens in our destructor),
 so I think we're okay there.  On the other hand, inflateEnd() and
 deflateEnd() are safe to call on the resulting structure too (since the
 internal state pointer gets reset to Z_NULL) - this will result in a
 Z_STREAM_ERROR, but we can safely ignore this.

 So, the current zlib implementation that I'm using is fine as is, and fine
 to add a call inflateEnd() or deflateEnd() if the init functions fail, but
 the real question is what other implementations do...

-- 
Ticket URL: <http://trac.xapian.org/ticket/325#comment:9>
Xapian <http://xapian.org/>
Xapian



More information about the Xapian-tickets mailing list