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
- QilNode.cs
- CapabilitiesState.cs
- ApplicationSecurityManager.cs
- Component.cs
- SelectManyQueryOperator.cs
- FormViewModeEventArgs.cs
- DataExpression.cs
- _SingleItemRequestCache.cs
- QilInvokeLateBound.cs
- DbCommandDefinition.cs
- CompositeFontParser.cs
- ConnectionConsumerAttribute.cs
- ExtendedPropertyInfo.cs
- XmlLanguage.cs
- AnnotationHelper.cs
- TickBar.cs
- DefaultTextStore.cs
- FormatControl.cs
- MemoryFailPoint.cs
- RowBinding.cs
- webeventbuffer.cs
- StylusTip.cs
- BooleanAnimationBase.cs
- DrawingVisual.cs
- TextViewSelectionProcessor.cs
- XamlHostingSection.cs
- NullableIntAverageAggregationOperator.cs
- ToolStripDropDownClosedEventArgs.cs
- SafeHandles.cs
- MobileControlsSectionHelper.cs
- ReadOnlyTernaryTree.cs
- EnumBuilder.cs
- LabelLiteral.cs
- CatalogPartCollection.cs
- InProcStateClientManager.cs
- AccessibleObject.cs
- PointHitTestResult.cs
- TextCompositionManager.cs
- PartialCachingAttribute.cs
- NativeMethods.cs
- HtmlShimManager.cs
- OleTxTransaction.cs
- ObjectRef.cs
- CalendarAutoFormatDialog.cs
- XomlDesignerLoader.cs
- PreservationFileWriter.cs
- Paragraph.cs
- ObjectRef.cs
- PackagingUtilities.cs
- TemplateAction.cs
- VersionUtil.cs
- basenumberconverter.cs
- HierarchicalDataTemplate.cs
- _NativeSSPI.cs
- ProtocolElement.cs
- SchemaTableOptionalColumn.cs
- WorkflowRequestContext.cs
- ContextBase.cs
- DefaultEvaluationContext.cs
- PersistenceTypeAttribute.cs
- MultilineStringConverter.cs
- PrintDocument.cs
- Point.cs
- WebPartAddingEventArgs.cs
- ConsoleKeyInfo.cs
- RecognizerInfo.cs
- DBSchemaRow.cs
- Char.cs
- SqlMethods.cs
- Monitor.cs
- ConfigurationConverterBase.cs
- Merger.cs
- ObjectQuery.cs
- BrowserTree.cs
- X500Name.cs
- DerivedKeySecurityTokenStub.cs
- MaskInputRejectedEventArgs.cs
- SafeArrayRankMismatchException.cs
- EnumerableCollectionView.cs
- BitmapImage.cs
- Size3D.cs
- ControlHelper.cs
- KnownTypeHelper.cs
- TreeViewHitTestInfo.cs
- PrintingPermission.cs
- CombinedGeometry.cs
- FontStretches.cs
- WSDualHttpBinding.cs
- MetadataArtifactLoaderCompositeResource.cs
- ManipulationStartingEventArgs.cs
- EventLogPermission.cs
- ValidationError.cs
- IIS7UserPrincipal.cs
- SqlBooleanMismatchVisitor.cs
- CollectionViewGroupRoot.cs
- StringFormat.cs
- LinkUtilities.cs
- Oid.cs
- PerspectiveCamera.cs
- FixedPosition.cs