@@ -6285,23 +6285,16 @@ mono_string_new_len_checked (MonoDomain *domain, const char *text, guint length,
6285
6285
return o ;
6286
6286
}
6287
6287
6288
- /**
6289
- * mono_string_new:
6290
- * \param text a pointer to a UTF-8 string
6291
- * \deprecated Use \c mono_string_new_checked in new code.
6292
- * This function asserts if it cannot allocate a new string.
6293
- * \returns A newly created string object which contains \p text.
6294
- */
6295
- MonoString *
6296
- mono_string_new (MonoDomain * domain , const char * text )
6288
+ static MonoString *
6289
+ mono_string_new_internal (MonoDomain * domain , const char * text )
6297
6290
{
6298
6291
MonoError error ;
6299
6292
MonoString * res = NULL ;
6300
6293
res = mono_string_new_checked (domain , text , & error );
6301
6294
if (!is_ok (& error )) {
6302
6295
/* Mono API compatability: assert on Out of Memory errors,
6303
- * return NULL otherwise (most likely an invalid UTF-8 byte
6304
- * sequence). */
6296
+ * return NULL otherwise (most likely an invalid UTF-8 byte
6297
+ * sequence). */
6305
6298
if (mono_error_get_error_code (& error ) == MONO_ERROR_OUT_OF_MEMORY )
6306
6299
mono_error_assert_ok (& error );
6307
6300
else
@@ -6310,6 +6303,19 @@ mono_string_new (MonoDomain *domain, const char *text)
6310
6303
return res ;
6311
6304
}
6312
6305
6306
+ /**
6307
+ * mono_string_new:
6308
+ * \param text a pointer to a UTF-8 string
6309
+ * \deprecated Use \c mono_string_new_checked in new code.
6310
+ * This function asserts if it cannot allocate a new string.
6311
+ * \returns A newly created string object which contains \p text.
6312
+ */
6313
+ MonoString *
6314
+ mono_string_new (MonoDomain * domain , const char * text )
6315
+ {
6316
+ return mono_string_new_internal (domain , text );
6317
+ }
6318
+
6313
6319
/**
6314
6320
* mono_string_new_checked:
6315
6321
* \param text a pointer to an utf8 string
@@ -6380,16 +6386,7 @@ mono_string_new_wrapper (const char *text)
6380
6386
{
6381
6387
MONO_REQ_GC_UNSAFE_MODE ;
6382
6388
6383
- MonoDomain * domain = mono_domain_get ();
6384
-
6385
- if (text ) {
6386
- MonoError error ;
6387
- MonoString * result = mono_string_new_checked (domain , text , & error );
6388
- mono_error_assert_ok (& error );
6389
- return result ;
6390
- }
6391
-
6392
- return NULL ;
6389
+ return mono_string_new_internal (mono_domain_get (), text );
6393
6390
}
6394
6391
6395
6392
/**
0 commit comments