Track the initialized state of nstime_t on debug build.
Some nstime_t operations require and assume the input nstime is initialized (e.g. nstime_update) -- uninitialized input may cause silent failures which is difficult to reproduce / debug. Add an explicit flag to track the state (limited to debug build only). Also fixed an use case in hpa (time of last_purge).
This commit is contained in:
@@ -3,10 +3,19 @@
|
||||
|
||||
/* Maximum supported number of seconds (~584 years). */
|
||||
#define NSTIME_SEC_MAX KQU(18446744072)
|
||||
#define NSTIME_ZERO_INITIALIZER {0}
|
||||
|
||||
#define NSTIME_MAGIC ((uint32_t)0xb8a9ce37)
|
||||
#ifdef JEMALLOC_DEBUG
|
||||
# define NSTIME_ZERO_INITIALIZER {0, NSTIME_MAGIC}
|
||||
#else
|
||||
# define NSTIME_ZERO_INITIALIZER {0}
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint64_t ns;
|
||||
#ifdef JEMALLOC_DEBUG
|
||||
uint32_t magic; /* Tracks if initialized. */
|
||||
#endif
|
||||
} nstime_t;
|
||||
|
||||
static const nstime_t zero = NSTIME_ZERO_INITIALIZER;
|
||||
|
Reference in New Issue
Block a user