Browse Source

Trim nulls from the end of most strings

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2284 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 19 years ago
parent
commit
c63173012b
  1. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorDebug/ICorDebugStringValue.cs
  2. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedDocument.cs
  3. 9
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/Util.cs

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorDebug/ICorDebugStringValue.cs

@ -16,7 +16,7 @@ namespace Debugger.Wrappers.CorDebug @@ -16,7 +16,7 @@ namespace Debugger.Wrappers.CorDebug
{
public string String {
get {
return Util.GetString(GetString);
return Util.GetString(GetString, 64, false);
}
}
}

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorSym/ISymUnmanagedDocument.cs

@ -16,7 +16,7 @@ namespace Debugger.Wrappers.CorSym @@ -16,7 +16,7 @@ namespace Debugger.Wrappers.CorSym
{
public string URL {
get {
return Util.GetString(GetURL, 0);
return Util.GetString(GetURL, 256, true);
}
}
}

9
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/Util.cs

@ -18,10 +18,10 @@ namespace Debugger.Wrappers @@ -18,10 +18,10 @@ namespace Debugger.Wrappers
{
public static string GetString(UnmanagedStringGetter getter)
{
return GetString(getter, 64);
return GetString(getter, 64, true);
}
public static string GetString(UnmanagedStringGetter getter, uint defaultLenght)
public static string GetString(UnmanagedStringGetter getter, uint defaultLenght, bool trim)
{
string managedString;
IntPtr unmanagedString;
@ -40,6 +40,11 @@ namespace Debugger.Wrappers @@ -40,6 +40,11 @@ namespace Debugger.Wrappers
// Return managed string and free unmanaged memory
managedString = Marshal.PtrToStringUni(unmanagedString, (int)exactLenght);
//Console.WriteLine("Marshaled string from COM: \"" + managedString + "\" lenght=" + managedString.Length + " arrayLenght=" + exactLenght);
// The API might or might not include terminating null at the end
if (trim) {
managedString = managedString.TrimEnd('\0');
}
Marshal.FreeHGlobal(unmanagedString);
return managedString;
}

Loading…
Cancel
Save