Merge pull request #2323 from esdrubal/servicemodel
[mono.git] / mono / metadata / string-icalls.c
index 0927141e7925f92d753c6579aa0905c816131f22..dc5e9ec57c936470ad4871fd1f531e139a95e797 100644 (file)
@@ -11,7 +11,6 @@
 #include <config.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include <signal.h>
 #include <string.h>
 #include "mono/utils/mono-membar.h"
 #include <mono/metadata/string-icalls.h>
@@ -24,7 +23,7 @@
 #include <mono/metadata/debug-helpers.h>
 #include <mono/metadata/profiler.h>
 #include <mono/metadata/profiler-private.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
 
 /* This function is redirected to String.CreateString ()
    by mono_marshal_get_native_wrapper () */
@@ -37,26 +36,29 @@ ves_icall_System_String_ctor_RedirectToCreateString (void)
 MonoString *
 ves_icall_System_String_InternalAllocateStr (gint32 length)
 {
-       return mono_string_new_size(mono_domain_get (), length);
+       MonoError error;
+       MonoString *str = mono_string_new_size_checked (mono_domain_get (), length, &error);
+       mono_error_raise_exception (&error);
+
+       return str;
 }
 
 MonoString  *
 ves_icall_System_String_InternalIntern (MonoString *str)
 {
        MonoString *res;
-       MONO_ARCH_SAVE_REGS;
 
        res = mono_string_intern(str);
-       if (!res)
-               mono_raise_exception (mono_domain_get ()->out_of_memory_ex);
+       if (!res) {
+               mono_set_pending_exception (mono_domain_get ()->out_of_memory_ex);
+               return NULL;
+       }
        return res;
 }
 
 MonoString * 
 ves_icall_System_String_InternalIsInterned (MonoString *str)
 {
-       MONO_ARCH_SAVE_REGS;
-
        return mono_string_is_interned(str);
 }
 
@@ -65,5 +67,6 @@ ves_icall_System_String_GetLOSLimit (void)
 {
        int limit = mono_gc_get_los_limit ();
 
-       return (limit - 2 - sizeof (MonoString)) / 2;
+       return (limit - 2 - G_STRUCT_OFFSET (MonoString, chars)) / 2;
 }
+