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
- Query.cs
- DSACryptoServiceProvider.cs
- SendMailErrorEventArgs.cs
- GradientStopCollection.cs
- EdmProviderManifest.cs
- DesignerDataConnection.cs
- MergeLocalizationDirectives.cs
- odbcmetadatacollectionnames.cs
- ImmutableCommunicationTimeouts.cs
- HybridDictionary.cs
- ToolboxDataAttribute.cs
- TrackingServices.cs
- COM2ExtendedTypeConverter.cs
- milexports.cs
- _DomainName.cs
- StringAnimationBase.cs
- Schema.cs
- ItemCheckEvent.cs
- DataFieldEditor.cs
- InfocardChannelParameter.cs
- SharedPerformanceCounter.cs
- Adorner.cs
- SystemColors.cs
- ConfigXmlComment.cs
- StringDictionary.cs
- PersistenceContext.cs
- LinqDataSourceHelper.cs
- ToolStripStatusLabel.cs
- CommandEventArgs.cs
- ToolStripItemImageRenderEventArgs.cs
- CompositeScriptReferenceEventArgs.cs
- ChannelSinkStacks.cs
- Condition.cs
- Message.cs
- SqlConnectionHelper.cs
- PeerNearMe.cs
- FixedTextPointer.cs
- EnlistmentState.cs
- HMACSHA512.cs
- XmlUtil.cs
- ThemeDictionaryExtension.cs
- GZipDecoder.cs
- Rect3DConverter.cs
- CompModSwitches.cs
- ServiceOperationParameter.cs
- CLSCompliantAttribute.cs
- ThrowHelper.cs
- EventBookmark.cs
- HtmlTableCellCollection.cs
- CodeIdentifier.cs
- UpdatePanelTrigger.cs
- __ComObject.cs
- Resources.Designer.cs
- RawStylusInputReport.cs
- StructuredTypeEmitter.cs
- ApplicationInterop.cs
- DefaultPropertiesToSend.cs
- CodeDomExtensionMethods.cs
- StylusLogic.cs
- filewebresponse.cs
- TypeUtils.cs
- CustomAttributeFormatException.cs
- DefaultValueAttribute.cs
- OraclePermission.cs
- ListControlConvertEventArgs.cs
- FacetChecker.cs
- FamilyTypefaceCollection.cs
- MenuAutoFormat.cs
- OutputWindow.cs
- RectKeyFrameCollection.cs
- Unit.cs
- DebugHandleTracker.cs
- DescriptionCreator.cs
- IndentedWriter.cs
- StorageRoot.cs
- ConfigurationValue.cs
- SortedList.cs
- ConsumerConnectionPointCollection.cs
- SoapTypeAttribute.cs
- PackageRelationshipCollection.cs
- IDQuery.cs
- SiteMembershipCondition.cs
- CopyOfAction.cs
- DirectionalLight.cs
- cookiecontainer.cs
- CodeFieldReferenceExpression.cs
- CanExecuteRoutedEventArgs.cs
- MembershipPasswordException.cs
- WebBrowserEvent.cs
- Calendar.cs
- TextMarkerSource.cs
- ParameterReplacerVisitor.cs
- CompoundFileIOPermission.cs
- HtmlElement.cs
- FreezableDefaultValueFactory.cs
- FileAuthorizationModule.cs
- SortDescription.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- TableCell.cs
- DataTableMappingCollection.cs