[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Lzip-bug] Restarting an lzip member at any time
From: |
Ersek, Laszlo |
Subject: |
Re: [Lzip-bug] Restarting an lzip member at any time |
Date: |
Fri, 11 Dec 2009 20:35:17 +0100 (CET) |
On Fri, 11 Dec 2009, Antonio Diaz Diaz wrote:
Hello list,
Jacob Rief wrote:
Why don't you declare a zero sized
C-struct, say struct LZ_Decoder {}; and struct LZ_Encoder {};
Those are empty structures, not zero sized structures.
a) C99, 6.5.3.4 The sizeof operator, EXAMPLE 2: "Another use of the sizeof
operator is to compute the number of elements in an array":
sizeof array / sizeof array[0]
b) http://www2.research.att.com/~bs/bs_faq2.html#sizeof-empty
Why is the size of an empty class not zero?
To ensure that the addresses of two different objects will be different.
rewrite the prototypes of the functions to expect a pointer onto these
dummy structs. This would make the code of the lzlib clients a lot
typesafer, so that mixing up a decoder with an encoder is detected
during compile time instead of runtime.
What do you think about this change? Should I use a typedef so that C
programs can declare variables this way:
LZ_Encoder * encoder;
instead of the standard C
struct LZ_Encoder * encoder;
?
I believe that "bringing out" structure tags into the ordinary identifier
namespace via typedefs is bad style in C. Personal preferences aside, both
libz and libbz2 do that, so you might want to follow their convention.
http://www.zlib.net/manual.html#struct%20z_stream_s
http://bzip.org/1.0.5/bzip2-manual-1.0.5.html#bzcompress-init
Cheers,
lacos
- [Lzip-bug] Restarting an lzip member at any time, Jacob Rief, 2009/12/07
- Re: [Lzip-bug] Restarting an lzip member at any time, Antonio Diaz Diaz, 2009/12/08
- Message not available
- Re: [Lzip-bug] Restarting an lzip member at any time, Antonio Diaz Diaz, 2009/12/11
- Re: [Lzip-bug] Restarting an lzip member at any time,
Ersek, Laszlo <=
- Re: [Lzip-bug] Restarting an lzip member at any time, Jacob Rief, 2009/12/11
- Re: [Lzip-bug] Restarting an lzip member at any time, John Reiser, 2009/12/11
- Re: [Lzip-bug] Restarting an lzip member at any time, Jacob Rief, 2009/12/11
- Re: [Lzip-bug] Restarting an lzip member at any time, Antonio Diaz Diaz, 2009/12/12
- Re: [Lzip-bug] Restarting an lzip member at any time, Jacob Rief, 2009/12/13
- Re: [Lzip-bug] Restarting an lzip member at any time, Antonio Diaz Diaz, 2009/12/14