File tree 1 file changed +14
-9
lines changed 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ public int Capacity
120
120
{
121
121
get { return _capacity ; }
122
122
}
123
-
123
+
124
124
/// <summary>
125
125
/// Check that a given limit is not greater than the capacity of a buffer from a given offset.
126
126
/// </summary>
@@ -129,17 +129,22 @@ public void CheckLimit(int limit)
129
129
{
130
130
if ( limit > _capacity )
131
131
{
132
- if ( bufferOverflow == null )
133
- throw new IndexOutOfRangeException ( string . Format ( "limit={0} is beyond capacity={1}" , limit , _capacity ) ) ;
132
+ TryResizeBuffer ( limit ) ;
133
+ }
134
+ }
134
135
135
- var newBuffer = bufferOverflow ( _capacity , limit ) ;
136
+ private void TryResizeBuffer ( int limit )
137
+ {
138
+ if ( bufferOverflow == null )
139
+ throw new IndexOutOfRangeException ( string . Format ( "limit={0} is beyond capacity={1}" , limit , _capacity ) ) ;
136
140
137
- if ( newBuffer == null )
138
- throw new IndexOutOfRangeException ( string . Format ( "limit={0} is beyond capacity={1}" , limit , _capacity ) ) ;
141
+ var newBuffer = bufferOverflow ( _capacity , limit ) ;
139
142
140
- Marshal . Copy ( ( IntPtr ) _pBuffer , newBuffer , 0 , _capacity ) ;
141
- Wrap ( newBuffer ) ;
142
- }
143
+ if ( newBuffer == null )
144
+ throw new IndexOutOfRangeException ( string . Format ( "limit={0} is beyond capacity={1}" , limit , _capacity ) ) ;
145
+
146
+ Marshal . Copy ( ( IntPtr ) _pBuffer , newBuffer , 0 , _capacity ) ;
147
+ Wrap ( newBuffer ) ;
143
148
}
144
149
145
150
/// <summary>
You can’t perform that action at this time.
0 commit comments