Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / clr / src / BCL / System / UnSafeCharBuffer.cs / 1 / UnSafeCharBuffer.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: UnSafeBuffer ** ** Purpose: A class to detect incorrect usage of UnSafeBuffer ** ** ===========================================================*/ namespace System { using System.Diagnostics; unsafe internal struct UnSafeCharBuffer{ char * m_buffer; int m_totalSize; int m_length; public UnSafeCharBuffer( char *buffer, int bufferSize) { BCLDebug.Assert( buffer != null, "buffer pointer can't be null." ); BCLDebug.Assert( bufferSize >= 0, "buffer size can't be negative." ); m_buffer = buffer; m_totalSize = bufferSize; m_length = 0; } public void AppendString(string stringToAppend) { if( String.IsNullOrEmpty( stringToAppend ) ) { return; } if ( (m_totalSize - m_length) < stringToAppend.Length ) { throw new IndexOutOfRangeException(); } fixed( char* pointerToString = stringToAppend ) { Buffer.memcpyimpl( (byte *) pointerToString, (byte*) (m_buffer + m_length), stringToAppend.Length * sizeof(char)); } m_length += stringToAppend.Length; BCLDebug.Assert(m_length <= m_totalSize, "Buffer has been overflowed!"); } public int Length { get { return m_length; } } } }
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ComIntegrationManifestGenerator.cs
- RegionIterator.cs
- SerializationException.cs
- DirtyTextRange.cs
- XmlAutoDetectWriter.cs
- formatstringdialog.cs
- EdmPropertyAttribute.cs
- SqlExpressionNullability.cs
- RawMouseInputReport.cs
- BufferBuilder.cs
- TemplateKeyConverter.cs
- CopyNodeSetAction.cs
- RecommendedAsConfigurableAttribute.cs
- AxisAngleRotation3D.cs
- TcpAppDomainProtocolHandler.cs
- Int32Converter.cs
- NativeMsmqMessage.cs
- StreamReader.cs
- CursorConverter.cs
- MediaScriptCommandRoutedEventArgs.cs
- ContentFileHelper.cs
- Binding.cs
- SoapObjectWriter.cs
- CapiSymmetricAlgorithm.cs
- EventDescriptor.cs
- PaintEvent.cs
- MessageQueueException.cs
- IteratorDescriptor.cs
- BuildProvidersCompiler.cs
- HMACMD5.cs
- ItemList.cs
- Cursor.cs
- TableStyle.cs
- FlowDocument.cs
- HostedElements.cs
- EventWaitHandle.cs
- PageContentCollection.cs
- DbMetaDataColumnNames.cs
- ExpressionBuilder.cs
- MenuBindingsEditor.cs
- SqlConnectionPoolGroupProviderInfo.cs
- AppDomainFactory.cs
- Hashtable.cs
- InheritedPropertyChangedEventArgs.cs
- CompiledQuery.cs
- ProxyWebPartManagerDesigner.cs
- WorkflowViewService.cs
- RemoteWebConfigurationHostServer.cs
- Token.cs
- EndpointIdentity.cs
- ResourceSetExpression.cs
- AssociationSetEnd.cs
- LiteralText.cs
- _BufferOffsetSize.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- ResourceCategoryAttribute.cs
- EntryPointNotFoundException.cs
- FileEnumerator.cs
- NavigatingCancelEventArgs.cs
- SystemBrushes.cs
- PropertyRecord.cs
- Line.cs
- RichTextBox.cs
- connectionpool.cs
- DataGridViewButtonCell.cs
- DBConnection.cs
- WebServiceParameterData.cs
- MgmtConfigurationRecord.cs
- ObjectDataSourceMethodEventArgs.cs
- WinFormsComponentEditor.cs
- Visual3D.cs
- path.cs
- CodeArrayCreateExpression.cs
- ListViewSortEventArgs.cs
- ActivityDesignerLayoutSerializers.cs
- UnsafeNativeMethodsMilCoreApi.cs
- StylusButton.cs
- WindowsSspiNegotiation.cs
- ButtonBase.cs
- PartialCachingAttribute.cs
- QualifiedCellIdBoolean.cs
- RouteValueDictionary.cs
- LinqDataSourceDeleteEventArgs.cs
- GZipStream.cs
- ConfigurationSettings.cs
- SQlBooleanStorage.cs
- SelectorAutomationPeer.cs
- EntityViewGenerator.cs
- _Rfc2616CacheValidators.cs
- ParameterRetriever.cs
- Group.cs
- AnonymousIdentificationModule.cs
- DataTable.cs
- BitConverter.cs
- SafeFreeMibTable.cs
- DesignerLabelAdapter.cs
- ConvertEvent.cs
- EdmRelationshipNavigationPropertyAttribute.cs
- DataGridViewComponentPropertyGridSite.cs
- WindowsListViewItem.cs