Function CE::Memory::Pointers::pointer_to_hash

Function Documentation

inline std::variant<uint8_t, uint16_t, uint32_t, uint64_t> CE::Memory::Pointers::pointer_to_hash(void *ptr, size_t hash_size_bytes)

Hashes the pointer address, never the pointed-to bytes.

Parameters:
  • ptr – Pointer address, borrowed and not dereferenced; may be null.

  • hash_size_bytes – Requested variant width: exactly 1, 2, 4 or 8 bytes.

Throws:

CE::Exceptions::invalid_args – For every other requested width. Collisions are possible. Address reuse and process relocation make this unsuitable as a persistent identity or object-lifetime token.

Returns:

Corresponding unsigned variant alternative. Smaller results reduce the FNV-1a value modulo their unsigned maximum, excluding that maximum; the eight-byte result retains all hash bits.