Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

glib: negate Marshaller compiler define #165

Open
wants to merge 1 commit into
base: gtk-sharp-2-12-branch
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions configure.in.in
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ AM_CONDITIONAL(ENABLE_MONOGETOPTIONS, test "x$has_mono" = "xtrue")

CSFLAGS="$DEBUG_FLAGS $CSDEFINES $WIN64DEFINES -unsafe"

if test "x$NET_4_6_SUPPORT" = "xtrue" ; then
CSFLAGS="$CSFLAGS -define:HAVE_NET_4_6"
if test "x$NET_4_6_SUPPORT" = "xfalse" ; then
CSFLAGS="$CSFLAGS -define:UTF8_SLOW_PATH"
fi
PKG_CHECK_MODULES(GLIB_2_31,
glib-2.0 >= 2.31,
Expand Down
11 changes: 6 additions & 5 deletions glib/Marshaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,17 @@ public static string Utf8PtrToString (IntPtr ptr)
return null;

int len = (int) (uint)glibsharp_strlen (ptr);
#if HAVE_NET_4_6

#if UTF8_SLOW_PATH
byte [] bytes = new byte [len];
Marshal.Copy (ptr, bytes, 0, len);
return System.Text.Encoding.UTF8.GetString (bytes);
#else
unsafe
{
var p = (byte*)ptr;
return System.Text.Encoding.UTF8.GetString (p, len);
}
#else
byte [] bytes = new byte [len];
Marshal.Copy (ptr, bytes, 0, len);
return System.Text.Encoding.UTF8.GetString (bytes);
#endif
}

Expand Down