private void ValidateAndUnregister(ByteStringStorage *value) { ulong index = (ulong)value; ulong hash = value->GetContentHash(); try { Tuple <IntPtr, ulong, string> item; if (!_immutableTracker.TryGetValue(index, out item)) { throw new ByteStringValidationException($"The ByteStream is being released as Immutable, but it was not registered. Potential buffer overflow detected."); } if (hash != item.Item2) { throw new ByteStringValidationException($"The ByteString in location {(ulong)value} and size {value->Length} was modified but it was created as immutable. {Environment.NewLine} {item.Item3}"); } } finally { _immutableTracker.Remove(index); } }
internal ByteString(ByteStringStorage *ptr) { this._pointer = ptr; }
internal ByteString(ByteStringStorage *ptr) { this._pointer = ptr; this.Key = ptr->Key; // We store the storage key }