Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / UnSafeCharBuffer.cs / 1305376 / 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; using System.Diagnostics.Contracts; unsafe internal struct UnSafeCharBuffer{ char * m_buffer; int m_totalSize; int m_length; [System.Security.SecurityCritical] // auto-generated public UnSafeCharBuffer( char *buffer, int bufferSize) { Contract.Assert( buffer != null, "buffer pointer can't be null." ); Contract.Assert( bufferSize >= 0, "buffer size can't be negative." ); m_buffer = buffer; m_totalSize = bufferSize; m_length = 0; } [System.Security.SecuritySafeCritical] // auto-generated 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; Contract.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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ObsoleteAttribute.cs
- RouteValueDictionary.cs
- SpellerInterop.cs
- SmuggledIUnknown.cs
- TextServicesCompartmentEventSink.cs
- TypedRowHandler.cs
- HandlerBase.cs
- UnsafeNativeMethodsCLR.cs
- Root.cs
- RequestQueue.cs
- OutputCacheSettingsSection.cs
- LayoutManager.cs
- XmlArrayItemAttribute.cs
- SimpleHandlerFactory.cs
- SignalGate.cs
- DebugHandleTracker.cs
- ArgumentsParser.cs
- DynamicUpdateCommand.cs
- SiteMapDataSourceView.cs
- SamlAssertionKeyIdentifierClause.cs
- WorkflowServiceHost.cs
- AttachedPropertyMethodSelector.cs
- DependencyObjectCodeDomSerializer.cs
- Border.cs
- CardSpacePolicyElement.cs
- Error.cs
- ChannelManagerBase.cs
- SqlDataSourceSelectingEventArgs.cs
- QilValidationVisitor.cs
- CollectionConverter.cs
- StreamingContext.cs
- DeclaredTypeValidator.cs
- StreamInfo.cs
- XmlDataLoader.cs
- RegexFCD.cs
- EntityDataSourceDataSelection.cs
- HtmlHistory.cs
- SecurityRuntime.cs
- BindingElement.cs
- GeneralTransform3D.cs
- externdll.cs
- ClientRolePrincipal.cs
- WebServiceMethodData.cs
- SubtreeProcessor.cs
- MouseCaptureWithinProperty.cs
- ConvertersCollection.cs
- SqlInternalConnectionSmi.cs
- AnimationLayer.cs
- ProgramNode.cs
- BindingNavigator.cs
- ArrangedElementCollection.cs
- ITextView.cs
- WpfWebRequestHelper.cs
- OpacityConverter.cs
- WebRequestModuleElement.cs
- WebServiceParameterData.cs
- RelationshipDetailsCollection.cs
- Image.cs
- AutoSizeToolBoxItem.cs
- StreamHelper.cs
- CollectionsUtil.cs
- TreeViewEvent.cs
- AnnotationAdorner.cs
- MachineKeySection.cs
- EntityConnection.cs
- TemplatePropertyEntry.cs
- Mapping.cs
- XmlCharacterData.cs
- FormViewInsertedEventArgs.cs
- SizeF.cs
- OleAutBinder.cs
- InputLanguageProfileNotifySink.cs
- GroupJoinQueryOperator.cs
- AndCondition.cs
- SoapInteropTypes.cs
- HttpCapabilitiesSectionHandler.cs
- DocumentScope.cs
- ExtenderControl.cs
- ChameleonKey.cs
- ConfigurationSection.cs
- XsdBuildProvider.cs
- Drawing.cs
- SqlUnionizer.cs
- IDReferencePropertyAttribute.cs
- MouseButton.cs
- ControlAdapter.cs
- QueryableDataSourceEditData.cs
- CodeRemoveEventStatement.cs
- PersonalizationProviderHelper.cs
- TypeUtil.cs
- VisualCollection.cs
- MessageSecurityOverMsmq.cs
- LinearGradientBrush.cs
- NTAccount.cs
- SafeThreadHandle.cs
- XmlSerializerOperationFormatter.cs
- DataContractSerializerMessageContractImporter.cs
- streamingZipPartStream.cs
- UpDownBaseDesigner.cs
- InplaceBitmapMetadataWriter.cs