Merge pull request #4152 from BrzVlad/misc-gc-altstack
[mono.git] / mono / metadata / marshal.c
index 87c55ba890ab4df66e7c419b5fa42b9b9bb5b57a..360938c244a1255313cd6af34e80af5cce8b8056 100644 (file)
@@ -40,7 +40,7 @@
 #include "mono/metadata/cominterop.h"
 #include "mono/metadata/remoting.h"
 #include "mono/metadata/reflection-internals.h"
-#include "mono/metadata/threadpool-ms.h"
+#include "mono/metadata/threadpool.h"
 #include "mono/metadata/handle.h"
 #include "mono/utils/mono-counters.h"
 #include "mono/utils/mono-tls.h"
@@ -1159,7 +1159,7 @@ mono_string_to_byvalwstr (gpointer dst, MonoString *src, int size)
        }
 
        len = MIN (size, (mono_string_length (src)));
-       memcpy (dst, mono_string_chars (src), size * 2);
+       memcpy (dst, mono_string_chars (src), len * 2);
        if (size <= mono_string_length (src))
                len--;
        *((gunichar2 *) dst + len) = 0;
@@ -2451,7 +2451,7 @@ mono_delegate_begin_invoke (MonoDelegate *delegate, gpointer *params)
                method = mono_get_delegate_invoke (klass);
        g_assert (method);
 
-       MonoAsyncResult *result = mono_threadpool_ms_begin_invoke (mono_domain_get (), (MonoObject*) delegate, method, params, &error);
+       MonoAsyncResult *result = mono_threadpool_begin_invoke (mono_domain_get (), (MonoObject*) delegate, method, params, &error);
        mono_error_set_pending_exception (&error);
        return result;
 }
@@ -2624,6 +2624,9 @@ mono_marshal_get_ptr_to_string_conv (MonoMethodPInvoke *piinfo, MonoMarshalSpec
        case MONO_NATIVE_VBBYREFSTR:
                return MONO_MARSHAL_CONV_LPSTR_STR;
        case MONO_NATIVE_LPTSTR:
+#ifdef TARGET_WIN32
+               *need_free = FALSE;
+#endif
                return MONO_MARSHAL_CONV_LPTSTR_STR;
        case MONO_NATIVE_BSTR:
                return MONO_MARSHAL_CONV_BSTR_STR;
@@ -3210,7 +3213,7 @@ mono_delegate_end_invoke (MonoDelegate *delegate, gpointer *params)
        } else
 #endif
        {
-               res = mono_threadpool_ms_end_invoke (ares, &out_args, &exc, &error);
+               res = mono_threadpool_end_invoke (ares, &out_args, &exc, &error);
                if (mono_error_set_pending_exception (&error))
                        return NULL;
        }