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
- SkinBuilder.cs
- BigInt.cs
- LinearKeyFrames.cs
- ConstNode.cs
- AllMembershipCondition.cs
- BamlRecordReader.cs
- MemoryMappedFile.cs
- FixedFlowMap.cs
- SecurityContextCookieSerializer.cs
- ConfigurationLocation.cs
- ImmComposition.cs
- DataGridTableCollection.cs
- ImageDrawing.cs
- MouseBinding.cs
- ObjectSet.cs
- ReadOnlyDataSource.cs
- EventLogRecord.cs
- MessageSmuggler.cs
- RegexReplacement.cs
- XmlFormatExtensionPointAttribute.cs
- ReachVisualSerializer.cs
- ConfigurationErrorsException.cs
- CryptoProvider.cs
- XmlSerializerFormatAttribute.cs
- Activity.cs
- CodeObjectCreateExpression.cs
- JapaneseCalendar.cs
- TaskExtensions.cs
- ChooseAction.cs
- PasswordRecovery.cs
- MultiplexingFormatMapping.cs
- Base64Stream.cs
- TextFragmentEngine.cs
- SqlInternalConnection.cs
- SymDocumentType.cs
- WpfPayload.cs
- DBDataPermissionAttribute.cs
- CollectionTypeElement.cs
- EntityDesignerUtils.cs
- WebServiceResponseDesigner.cs
- AutomationProperties.cs
- DbgCompiler.cs
- ShutDownListener.cs
- GlobalAllocSafeHandle.cs
- ToolStripDropDownMenu.cs
- WinInet.cs
- DataBoundControl.cs
- FormViewUpdateEventArgs.cs
- AttachmentService.cs
- AutoResizedEvent.cs
- SqlDelegatedTransaction.cs
- MutexSecurity.cs
- GeometryGroup.cs
- util.cs
- SQLDouble.cs
- Helper.cs
- UriSectionData.cs
- TagElement.cs
- _ConnectionGroup.cs
- EmptyStringExpandableObjectConverter.cs
- PropertyMetadata.cs
- WizardStepBase.cs
- WebPartConnectionsDisconnectVerb.cs
- SafeArrayTypeMismatchException.cs
- ToolZone.cs
- EntityParameter.cs
- Table.cs
- MetafileHeaderWmf.cs
- CompositionTarget.cs
- BinHexDecoder.cs
- DocumentPageHost.cs
- XmlSchemaAny.cs
- DateTimeFormatInfoScanner.cs
- IResourceProvider.cs
- NetworkInformationPermission.cs
- UpdateTracker.cs
- DataGridViewCellValueEventArgs.cs
- ScriptingRoleServiceSection.cs
- DataGridBoolColumn.cs
- SelectedGridItemChangedEvent.cs
- UrlPath.cs
- CompilerGeneratedAttribute.cs
- RequestQueryParser.cs
- DeploymentExceptionMapper.cs
- PointF.cs
- ScriptComponentDescriptor.cs
- GeneratedView.cs
- AsyncDataRequest.cs
- GridViewAutomationPeer.cs
- CreatingCookieEventArgs.cs
- Int32Storage.cs
- QueryResults.cs
- DropDownButton.cs
- QilStrConcat.cs
- ConfigurationProperty.cs
- TextServicesManager.cs
- DnsPermission.cs
- DataViewSetting.cs
- SchemaCollectionCompiler.cs
- DataGridViewSelectedRowCollection.cs