@@ -658,47 +658,6 @@ STRINGREF StringObject::NewString(INT32 length) {
658658 }
659659}
660660
661-
662- /* ==================================NewString===================================
663- **Action: Many years ago, VB didn't have the concept of a byte array, so enterprising
664- ** users created one by allocating a BSTR with an odd length and using it to
665- ** store bytes. A generation later, we're still stuck supporting this behavior.
666- ** The way that we do this is to take advantage of the difference between the
667- ** array length and the string length. The string length will always be the
668- ** number of characters between the start of the string and the terminating 0.
669- ** If we need an odd number of bytes, we'll take one wchar after the terminating 0.
670- ** (e.g. at position StringLength+1). The high-order byte of this wchar is
671- ** reserved for flags and the low-order byte is our odd byte. This function is
672- ** used to allocate a string of that shape, but we don't actually mark the
673- ** trailing byte as being in use yet.
674- **Returns: A newly allocated string. Null if length is less than 0.
675- **Arguments: length -- the length of the string to allocate
676- ** bHasTrailByte -- whether the string also has a trailing byte.
677- **Exceptions: OutOfMemoryException if AllocateString fails.
678- ==============================================================================*/
679- STRINGREF StringObject::NewString (INT32 length, BOOL bHasTrailByte) {
680- CONTRACTL {
681- GC_TRIGGERS;
682- MODE_COOPERATIVE;
683- PRECONDITION (length>=0 && length != INT32_MAX);
684- } CONTRACTL_END;
685-
686- STRINGREF pString;
687- if (length<0 || length == INT32_MAX) {
688- return NULL ;
689- } else if (length == 0 ) {
690- return GetEmptyString ();
691- } else {
692- pString = AllocateString (length);
693- _ASSERTE (pString->GetBuffer ()[length]==0 );
694- if (bHasTrailByte) {
695- _ASSERTE (pString->GetBuffer ()[length+1 ]==0 );
696- }
697- }
698-
699- return pString;
700- }
701-
702661// ========================================================================
703662// Creates a System.String object and initializes from
704663// the supplied null-terminated C string.
@@ -887,74 +846,6 @@ STRINGREF* StringObject::InitEmptyStringRefPtr() {
887846 return EmptyStringRefPtr;
888847}
889848
890- /* ============================InternalTrailByteCheck============================
891- **Action: Many years ago, VB didn't have the concept of a byte array, so enterprising
892- ** users created one by allocating a BSTR with an odd length and using it to
893- ** store bytes. A generation later, we're still stuck supporting this behavior.
894- ** The way that we do this is stick the trail byte in the sync block
895- ** whenever we encounter such a situation. Since we expect this to be a very corner case
896- ** accessing the sync block seems like a good enough solution
897- **
898- **Returns: True if <CODE>str</CODE> contains a VB trail byte, false otherwise.
899- **Arguments: str -- The string to be examined.
900- **Exceptions: None
901- ==============================================================================*/
902- BOOL StringObject::HasTrailByte () {
903- WRAPPER_NO_CONTRACT;
904-
905- SyncBlock * pSyncBlock = PassiveGetSyncBlock ();
906- if (pSyncBlock != NULL )
907- {
908- return pSyncBlock->HasCOMBstrTrailByte ();
909- }
910-
911- return FALSE ;
912- }
913-
914- /* =================================GetTrailByte=================================
915- **Action: If <CODE>str</CODE> contains a vb trail byte, returns a copy of it.
916- **Returns: True if <CODE>str</CODE> contains a trail byte. *bTrailByte is set to
917- ** the byte in question if <CODE>str</CODE> does have a trail byte, otherwise
918- ** it's set to 0.
919- **Arguments: str -- The string being examined.
920- ** bTrailByte -- An out param to hold the value of the trail byte.
921- **Exceptions: None.
922- ==============================================================================*/
923- BOOL StringObject::GetTrailByte (BYTE *bTrailByte) {
924- CONTRACTL
925- {
926- NOTHROW;
927- GC_NOTRIGGER;
928- MODE_ANY;
929- }
930- CONTRACTL_END;
931- _ASSERTE (bTrailByte);
932- *bTrailByte=0 ;
933-
934- BOOL retValue = HasTrailByte ();
935-
936- if (retValue)
937- {
938- *bTrailByte = GET_VB_TRAIL_BYTE (GetHeader ()->PassiveGetSyncBlock ()->GetCOMBstrTrailByte ());
939- }
940-
941- return retValue;
942- }
943-
944- /* =================================SetTrailByte=================================
945- **Action: Sets the trail byte in the sync block
946- **Returns: True.
947- **Arguments: str -- The string into which to set the trail byte.
948- ** bTrailByte -- The trail byte to be added to the string.
949- **Exceptions: None.
950- ==============================================================================*/
951- BOOL StringObject::SetTrailByte (BYTE bTrailByte) {
952- WRAPPER_NO_CONTRACT;
953-
954- GetHeader ()->GetSyncBlock ()->SetCOMBstrTrailByte (MAKE_VB_TRAIL_BYTE (bTrailByte));
955- return TRUE ;
956- }
957-
958849#ifdef USE_CHECKED_OBJECTREFS
959850
960851// -------------------------------------------------------------
0 commit comments