Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / 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; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ToolStripCustomTypeDescriptor.cs
- IDataContractSurrogate.cs
- ObjectNotFoundException.cs
- InputMethodStateTypeInfo.cs
- SupportingTokenProviderSpecification.cs
- EventInfo.cs
- SqlFormatter.cs
- BuildProvidersCompiler.cs
- DashStyles.cs
- PropertyItem.cs
- DictionaryEntry.cs
- FontStretch.cs
- cryptoapiTransform.cs
- XmlMapping.cs
- AtlasWeb.Designer.cs
- FileFormatException.cs
- PageCodeDomTreeGenerator.cs
- ValidationService.cs
- SqlConnectionPoolGroupProviderInfo.cs
- Stylus.cs
- PersonalizationStateInfo.cs
- ClientSideQueueItem.cs
- ConfigurationSection.cs
- SessionPageStatePersister.cs
- FrameworkElementFactory.cs
- DeadCharTextComposition.cs
- Point.cs
- TypeDescriptor.cs
- EntityContainerEntitySetDefiningQuery.cs
- XmlSchemaDocumentation.cs
- Rule.cs
- _SecureChannel.cs
- EntityTemplateUserControl.cs
- AnnotationHelper.cs
- Queue.cs
- SQLDecimal.cs
- FormCollection.cs
- SchemaInfo.cs
- ElementNotEnabledException.cs
- Utils.cs
- KnownTypes.cs
- ConnectionStringsExpressionBuilder.cs
- GridProviderWrapper.cs
- FrameworkContextData.cs
- BooleanFunctions.cs
- TransportManager.cs
- ListParaClient.cs
- ReferentialConstraint.cs
- ListControlConvertEventArgs.cs
- SmtpReplyReaderFactory.cs
- ErrorFormatterPage.cs
- XmlArrayItemAttributes.cs
- OutOfProcStateClientManager.cs
- Unit.cs
- Transform3DGroup.cs
- SecurityUtils.cs
- ContextMarshalException.cs
- MasterPageBuildProvider.cs
- FixedPageAutomationPeer.cs
- LogicalTreeHelper.cs
- ErrorHandler.cs
- CompareValidator.cs
- JournalEntryListConverter.cs
- InfoCardProofToken.cs
- ExcludeFromCodeCoverageAttribute.cs
- TextEncodedRawTextWriter.cs
- IntegerValidator.cs
- ClientSettingsProvider.cs
- SpeechDetectedEventArgs.cs
- NavigatorInput.cs
- SerializationSectionGroup.cs
- SelfIssuedAuthRSACryptoProvider.cs
- HandleCollector.cs
- ComContractElement.cs
- FontSource.cs
- storepermission.cs
- PageVisual.cs
- CodeArrayCreateExpression.cs
- KnownTypeAttribute.cs
- RenderTargetBitmap.cs
- AstTree.cs
- HybridDictionary.cs
- ProfileModule.cs
- XmlArrayItemAttributes.cs
- DataSpaceManager.cs
- StylusPointPropertyUnit.cs
- InstanceDataCollection.cs
- QilNode.cs
- EntityType.cs
- PlatformCulture.cs
- TextFormatterImp.cs
- QuaternionConverter.cs
- RemotingException.cs
- CodeTypeReferenceCollection.cs
- DateTimeFormat.cs
- FileRegion.cs
- ParagraphResult.cs
- NetworkInformationException.cs
- XmlWriterTraceListener.cs
- XMLSchema.cs