equal
deleted
inserted
replaced
26 const TInt KDeflateMaxDistance=(1<<KDeflateDistanceMag); |
26 const TInt KDeflateMaxDistance=(1<<KDeflateDistanceMag); |
27 |
27 |
28 // hashing |
28 // hashing |
29 const TUint KDeflateHashMultiplier=0xAC4B9B19u; |
29 const TUint KDeflateHashMultiplier=0xAC4B9B19u; |
30 const TInt KDeflateHashShift=24; |
30 const TInt KDeflateHashShift=24; |
|
31 |
|
32 #define COMPILE_TIME_ASSERT(e) \ |
|
33 switch (0) \ |
|
34 { \ |
|
35 case 0: \ |
|
36 case e: \ |
|
37 ; \ |
|
38 } |
|
39 |
31 |
40 |
32 /** |
41 /** |
33 Class HDeflateHash |
42 Class HDeflateHash |
34 @internalComponent |
43 @internalComponent |
35 @released |
44 @released |
123 @internalComponent |
132 @internalComponent |
124 @released |
133 @released |
125 */ |
134 */ |
126 inline HDeflateHash* HDeflateHash::NewLC(TInt aLinks) |
135 inline HDeflateHash* HDeflateHash::NewLC(TInt aLinks) |
127 { |
136 { |
128 //return new(HMem::Alloc(0,_FOFF(HDeflateHash,iOffset[Min(aLinks,KDeflateMaxDistance)]))) HDeflateHash; |
137 #if __GNUC__ >= 4 |
129 return new(new char[_FOFF(HDeflateHash,iOffset[Min(aLinks,KDeflateMaxDistance)])]) HDeflateHash; |
138 // Try to detect if the class' layout has changed. |
130 } |
139 COMPILE_TIME_ASSERT( sizeof(HDeflateHash) == 1028 ); |
|
140 COMPILE_TIME_ASSERT( sizeof(TOffset) == 2 ); |
|
141 COMPILE_TIME_ASSERT( offsetof(HDeflateHash, iHash) < offsetof(HDeflateHash, iOffset) ); |
|
142 |
|
143 // Compute the size of the class, including rounding it up to a multiple of 4 |
|
144 // bytes. |
|
145 |
|
146 unsigned n = sizeof(TInt) * 256 + sizeof(TOffset) * Min(aLinks, KDeflateMaxDistance); |
|
147 |
|
148 while (n & 0x1f) |
|
149 { |
|
150 n++; |
|
151 } |
|
152 // Allocate the raw memory ... |
|
153 void* p = ::operator new(n); |
|
154 // ... And create the object in that memory. |
|
155 return new(p) HDeflateHash; |
|
156 #else |
|
157 return new(new char[_FOFF(HDeflateHash,iOffset[Min(aLinks,KDeflateMaxDistance)])]) HDeflateHash; |
|
158 #endif |
|
159 } |
|
160 |
|
161 |
131 |
162 |
132 /** |
163 /** |
133 Hash function for HDeflateHash |
164 Hash function for HDeflateHash |
134 @param aPtr |
165 @param aPtr |
135 @return Hash value |
166 @return Hash value |