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
- NativeObjectSecurity.cs
- Freezable.cs
- DeviceFilterEditorDialog.cs
- DecimalAnimationBase.cs
- ImpersonationContext.cs
- RtfFormatStack.cs
- DataGridColumnHeadersPresenter.cs
- compensatingcollection.cs
- DelegatedStream.cs
- InplaceBitmapMetadataWriter.cs
- PlainXmlWriter.cs
- TextStore.cs
- SortKey.cs
- Subtree.cs
- ResourceContainer.cs
- UnsafeNativeMethods.cs
- ResourceDescriptionAttribute.cs
- CodePageUtils.cs
- DbRetry.cs
- ToolStripSeparatorRenderEventArgs.cs
- DataTableExtensions.cs
- RootBrowserWindowProxy.cs
- MsdtcWrapper.cs
- LoginDesigner.cs
- HistoryEventArgs.cs
- SqlCacheDependencyDatabase.cs
- LogReserveAndAppendState.cs
- ItemChangedEventArgs.cs
- FigureHelper.cs
- ObjectContextServiceProvider.cs
- ErrorStyle.cs
- XmlnsCache.cs
- LinearKeyFrames.cs
- RegistrySecurity.cs
- StrokeNodeOperations2.cs
- login.cs
- CompiledRegexRunner.cs
- CellParaClient.cs
- SimpleLine.cs
- InfiniteIntConverter.cs
- NumericUpDownAcceleration.cs
- WebPartTransformerAttribute.cs
- TransactionManager.cs
- ArrangedElement.cs
- ExpressionLexer.cs
- FileDialogPermission.cs
- XmlWriterDelegator.cs
- Size.cs
- DCSafeHandle.cs
- GiveFeedbackEvent.cs
- SQLInt16Storage.cs
- TrackingMemoryStream.cs
- PeerToPeerException.cs
- NumberFunctions.cs
- ComPlusInstanceProvider.cs
- Container.cs
- LinkGrep.cs
- ScriptManager.cs
- HttpAsyncResult.cs
- AutomationEventArgs.cs
- EdmScalarPropertyAttribute.cs
- StringBuilder.cs
- ItemDragEvent.cs
- EdmProperty.cs
- ByteStream.cs
- HttpMethodAttribute.cs
- WizardForm.cs
- HttpModuleAction.cs
- SqlOuterApplyReducer.cs
- RightNameExpirationInfoPair.cs
- CorrelationQuery.cs
- InputEventArgs.cs
- QueryCacheKey.cs
- SqlDataSourceFilteringEventArgs.cs
- Rights.cs
- NativeCppClassAttribute.cs
- EnumMember.cs
- SchemaContext.cs
- BrowserCapabilitiesFactoryBase.cs
- _SingleItemRequestCache.cs
- EntityDataSourceEntitySetNameItem.cs
- BoolExpressionVisitors.cs
- DetailsViewInsertEventArgs.cs
- Delegate.cs
- ObjectItemCollection.cs
- ToolStripSeparatorRenderEventArgs.cs
- DomNameTable.cs
- EditCommandColumn.cs
- HttpHandler.cs
- ClientScriptManagerWrapper.cs
- TypeDescriptor.cs
- SHA1CryptoServiceProvider.cs
- SQLInt32.cs
- DockPattern.cs
- Baml2006ReaderFrame.cs
- GridViewSelectEventArgs.cs
- WebUtil.cs
- CompositeFontParser.cs
- XmlBinaryReader.cs
- PriorityItem.cs