armink / FlashDB

An ultra-lightweight database that supports key-value and time series data | 一款支持 KV 数据和时序数据的超轻量级数据库
Apache License 2.0
1.71k stars 399 forks source link

Replaced `~0UL` in max value checks #243

Closed fzi-haxel closed 9 months ago

fzi-haxel commented 9 months ago

The actual value of ~0UL is architecture dependent. The unsigned long type must be at least 32 bits, but can be larger. Especially on 64-bit systems, unsigned long usually is 64 bits long, for which ~0UL will result in 0xFFFFFFFFFFFFFFFF instead of 0xFFFFFFFF. If this is the case, comparisons like kv->len == ~0UL, where kv->len is of type uint32_t, are always false. This commit replaces ~0UL with the appropriate max value defines from stdint.h.

armink commented 9 months ago

nice improvement