From: Alex Rousskov Date: Sun, 20 Jan 2013 01:50:52 +0000 (-0700) Subject: Use signed type for StoreMapSliceId because we use -1 as an "unset" value. X-Git-Tag: SQUID_3_5_0_1~444^2~77 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f13833e94e7f85c3a3271dd2bdefe6f1d4050732;p=thirdparty%2Fsquid.git Use signed type for StoreMapSliceId because we use -1 as an "unset" value. Initialize slice.next to be "unset". This should not be necessary in most cases, but reduces the probability that a half-made writeable entry cannot be freed properly because it contains an invalid slice.next value. Losing the bit to store ID sign is not a big deal: Since slices always contain non-trivial number of bytes for metadata, it is unlikely that all 32 (but less than 33) bits would be required to store slice IDs in the future. --- diff --git a/src/ipc/StoreMap.h b/src/ipc/StoreMap.h index a8975301fb..19c6990761 100644 --- a/src/ipc/StoreMap.h +++ b/src/ipc/StoreMap.h @@ -9,13 +9,13 @@ namespace Ipc { -typedef uint32_t StoreMapSliceId; +typedef int32_t StoreMapSliceId; /// a piece of Store entry, linked to other pieces, forming a chain class StoreMapSlice { public: - StoreMapSlice(): next(0), size(0) {} + StoreMapSlice(): next(-1), size(0) {} StoreMapSliceId next; ///< ID of the next slice occupied by the entry uint32_t size; ///< slice contents size