@@ -38,7 +38,7 @@ protected abstract OdbBackendOperations SupportedOperations
38
38
/// </summary>
39
39
/// <param name="bytes">Number of bytes to allocate</param>
40
40
/// <returns>An Stream for you to write to and then return. Do not dispose this object before returning it.</returns>
41
- protected unsafe Stream Allocate ( long bytes )
41
+ protected unsafe UnmanagedMemoryStream Allocate ( long bytes )
42
42
{
43
43
if ( bytes < 0 ||
44
44
( UIntPtr . Size == sizeof ( int ) && bytes > int . MaxValue ) )
@@ -56,7 +56,7 @@ protected unsafe Stream Allocate(long bytes)
56
56
/// </summary>
57
57
public abstract int Read (
58
58
ObjectId id ,
59
- out Stream data ,
59
+ out UnmanagedMemoryStream data ,
60
60
out ObjectType objectType ) ;
61
61
62
62
/// <summary>
@@ -65,7 +65,7 @@ public abstract int Read(
65
65
public abstract int ReadPrefix (
66
66
string shortSha ,
67
67
out ObjectId oid ,
68
- out Stream data ,
68
+ out UnmanagedMemoryStream data ,
69
69
out ObjectType objectType ) ;
70
70
71
71
/// <summary>
@@ -242,21 +242,18 @@ private unsafe static int Read(
242
242
return ( int ) GitErrorCode . Error ;
243
243
}
244
244
245
- Stream dataStream = null ;
245
+ UnmanagedMemoryStream memoryStream = null ;
246
246
247
247
try
248
248
{
249
249
ObjectType objectType ;
250
- int toReturn = odbBackend . Read ( new ObjectId ( oid ) , out dataStream , out objectType ) ;
250
+ int toReturn = odbBackend . Read ( new ObjectId ( oid ) , out memoryStream , out objectType ) ;
251
251
252
252
if ( toReturn != 0 )
253
253
{
254
254
return toReturn ;
255
255
}
256
256
257
- // Caller is expected to give us back a stream created with the Allocate() method.
258
- var memoryStream = dataStream as UnmanagedMemoryStream ;
259
-
260
257
if ( memoryStream == null )
261
258
{
262
259
return ( int ) GitErrorCode . Error ;
@@ -276,9 +273,9 @@ private unsafe static int Read(
276
273
}
277
274
finally
278
275
{
279
- if ( dataStream != null )
276
+ if ( memoryStream != null )
280
277
{
281
- dataStream . Dispose ( ) ;
278
+ memoryStream . Dispose ( ) ;
282
279
}
283
280
}
284
281
@@ -305,7 +302,7 @@ private unsafe static int ReadPrefix(
305
302
return ( int ) GitErrorCode . Error ;
306
303
}
307
304
308
- Stream dataStream = null ;
305
+ UnmanagedMemoryStream memoryStream = null ;
309
306
310
307
try
311
308
{
@@ -314,16 +311,13 @@ private unsafe static int ReadPrefix(
314
311
ObjectId oid ;
315
312
ObjectType objectType ;
316
313
317
- int toReturn = odbBackend . ReadPrefix ( shortSha , out oid , out dataStream , out objectType ) ;
314
+ int toReturn = odbBackend . ReadPrefix ( shortSha , out oid , out memoryStream , out objectType ) ;
318
315
319
316
if ( toReturn != 0 )
320
317
{
321
318
return toReturn ;
322
319
}
323
320
324
- // Caller is expected to give us back a stream created with the Allocate() method.
325
- var memoryStream = dataStream as UnmanagedMemoryStream ;
326
-
327
321
if ( memoryStream == null )
328
322
{
329
323
return ( int ) GitErrorCode . Error ;
@@ -343,9 +337,9 @@ private unsafe static int ReadPrefix(
343
337
}
344
338
finally
345
339
{
346
- if ( null != dataStream )
340
+ if ( memoryStream != null )
347
341
{
348
- dataStream . Dispose ( ) ;
342
+ memoryStream . Dispose ( ) ;
349
343
}
350
344
}
351
345
0 commit comments