Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2014-05-24 11:10:44 +0400
committernulltoken <emeric.fermas@gmail.com>2014-06-07 15:58:49 +0400
commitdd9d358ce1e5fcfc65de5bef6f60774added3822 (patch)
tree8b2369990c4987285faedad4e092f830b2a542cd /LibGit2Sharp
parente24b4d02f6bbb01d668920feb25bf78aecddaa82 (diff)
Make OdbBackend Read[Prefix]() return UnmanagedMemoryStream
Diffstat (limited to 'LibGit2Sharp')
-rw-r--r--LibGit2Sharp/OdbBackend.cs28
1 files changed, 11 insertions, 17 deletions
diff --git a/LibGit2Sharp/OdbBackend.cs b/LibGit2Sharp/OdbBackend.cs
index 04b43a72..db2d8b08 100644
--- a/LibGit2Sharp/OdbBackend.cs
+++ b/LibGit2Sharp/OdbBackend.cs
@@ -38,7 +38,7 @@ namespace LibGit2Sharp
/// </summary>
/// <param name="bytes">Number of bytes to allocate</param>
/// <returns>An Stream for you to write to and then return. Do not dispose this object before returning it.</returns>
- protected unsafe Stream Allocate(long bytes)
+ protected unsafe UnmanagedMemoryStream Allocate(long bytes)
{
if (bytes < 0 ||
(UIntPtr.Size == sizeof(int) && bytes > int.MaxValue))
@@ -56,7 +56,7 @@ namespace LibGit2Sharp
/// </summary>
public abstract int Read(
ObjectId id,
- out Stream data,
+ out UnmanagedMemoryStream data,
out ObjectType objectType);
/// <summary>
@@ -65,7 +65,7 @@ namespace LibGit2Sharp
public abstract int ReadPrefix(
string shortSha,
out ObjectId oid,
- out Stream data,
+ out UnmanagedMemoryStream data,
out ObjectType objectType);
/// <summary>
@@ -242,21 +242,18 @@ namespace LibGit2Sharp
return (int)GitErrorCode.Error;
}
- Stream dataStream = null;
+ UnmanagedMemoryStream memoryStream = null;
try
{
ObjectType objectType;
- int toReturn = odbBackend.Read(new ObjectId(oid), out dataStream, out objectType);
+ int toReturn = odbBackend.Read(new ObjectId(oid), out memoryStream, out objectType);
if (toReturn != 0)
{
return toReturn;
}
- // Caller is expected to give us back a stream created with the Allocate() method.
- var memoryStream = dataStream as UnmanagedMemoryStream;
-
if (memoryStream == null)
{
return (int)GitErrorCode.Error;
@@ -276,9 +273,9 @@ namespace LibGit2Sharp
}
finally
{
- if (dataStream != null)
+ if (memoryStream != null)
{
- dataStream.Dispose();
+ memoryStream.Dispose();
}
}
@@ -305,7 +302,7 @@ namespace LibGit2Sharp
return (int)GitErrorCode.Error;
}
- Stream dataStream = null;
+ UnmanagedMemoryStream memoryStream = null;
try
{
@@ -314,16 +311,13 @@ namespace LibGit2Sharp
ObjectId oid;
ObjectType objectType;
- int toReturn = odbBackend.ReadPrefix(shortSha, out oid, out dataStream, out objectType);
+ int toReturn = odbBackend.ReadPrefix(shortSha, out oid, out memoryStream, out objectType);
if (toReturn != 0)
{
return toReturn;
}
- // Caller is expected to give us back a stream created with the Allocate() method.
- var memoryStream = dataStream as UnmanagedMemoryStream;
-
if (memoryStream == null)
{
return (int)GitErrorCode.Error;
@@ -343,9 +337,9 @@ namespace LibGit2Sharp
}
finally
{
- if (null != dataStream)
+ if (memoryStream != null)
{
- dataStream.Dispose();
+ memoryStream.Dispose();
}
}