Merge pull request #4621 from alexanderkyte/strdup_env
[mono.git] / mono / metadata / icall.c
index e2e6a7352ae8c59c27806a6935c51b10506f0919..cb562cde7613af2419d55b049d8a3a7ece434449 100644 (file)
@@ -732,14 +732,6 @@ ves_icall_System_Array_ClearInternal (MonoArray *arr, int idx, int length)
        mono_gc_bzero_atomic (mono_array_addr_with_size_fast (arr, sz, idx), length * sz);
 }
 
-ICALL_EXPORT MonoArray*
-ves_icall_System_Array_Clone (MonoArray *arr)
-{
-       MonoError error;
-       MonoArray *result = mono_array_clone_checked (arr, &error);
-       mono_error_set_pending_exception (&error);
-       return result;
-}
 
 ICALL_EXPORT gboolean
 ves_icall_System_Array_FastCopy (MonoArray *source, int source_idx, MonoArray* dest, int dest_idx, int length)
@@ -6404,6 +6396,8 @@ ICALL_EXPORT MonoReflectionType *
 ves_icall_Remoting_RealProxy_InternalGetProxyType (MonoTransparentProxy *tp)
 {
        MonoError error;
+       g_assert (tp != NULL && mono_object_class (tp) == mono_defaults.transparent_proxy_class);
+       g_assert (tp->remote_class != NULL && tp->remote_class->proxy_class != NULL);
        MonoReflectionType *ret = mono_type_get_object_checked (mono_object_domain (tp), &tp->remote_class->proxy_class->byval_arg, &error);
        mono_error_set_pending_exception (&error);
 
@@ -6524,7 +6518,7 @@ ves_icall_System_Environment_GetIs64BitOperatingSystem (void)
 ICALL_EXPORT MonoStringHandle
 ves_icall_System_Environment_GetEnvironmentVariable_native (const gchar *utf8_name, MonoError *error)
 {
-       const gchar *value;
+       gchar *value;
 
        if (utf8_name == NULL)
                return NULL_HANDLE_STRING;
@@ -6534,7 +6528,9 @@ ves_icall_System_Environment_GetEnvironmentVariable_native (const gchar *utf8_na
        if (value == 0)
                return NULL_HANDLE_STRING;
        
-       return mono_string_new_handle (mono_domain_get (), value, error);
+       MonoStringHandle res = mono_string_new_handle (mono_domain_get (), value, error);
+       g_free (value);
+       return res;
 }
 
 /*
@@ -6562,7 +6558,7 @@ char **environ;
 #endif
 
 ICALL_EXPORT MonoArray *
-ves_icall_System_Environment_GetCoomandLineArgs (void)
+ves_icall_System_Environment_GetCommandLineArgs (void)
 {
        MonoError error;
        MonoArray *result = mono_runtime_get_main_args_checked (&error);
@@ -8095,12 +8091,12 @@ mono_icall_cleanup (void)
 
 /**
  * mono_add_internal_call:
- * @name: method specification to surface to the managed world
- * @method: pointer to a C method to invoke when the method is called
+ * \param name method specification to surface to the managed world
+ * \param method pointer to a C method to invoke when the method is called
  *
- * This method surfaces the C function pointed by @method as a method
+ * This method surfaces the C function pointed by \p method as a method
  * that has been surfaced in managed code with the method specified in
- * @name as an internal call.
+ * \p name as an internal call.
  *
  * Internal calls are surfaced to all app domains loaded and they are
  * accessibly by a type with the specified name.
@@ -8111,15 +8107,16 @@ mono_icall_cleanup (void)
  *
  * For example, the following are all valid declarations:
  *
- * "MyApp.Services.ScriptService:Accelerate"
- * "MyApp.Services.ScriptService:Slowdown(int,bool)"
+ * \c MyApp.Services.ScriptService:Accelerate
+ *
+ * \c MyApp.Services.ScriptService:Slowdown(int,bool)
  *
  * You use method parameters in cases where there might be more than
  * one surface method to managed code.  That way you can register different
  * internal calls for different method overloads.
  *
  * The internal calls are invoked with no marshalling.   This means that .NET
- * types like System.String are exposed as `MonoString *` parameters.   This is
+ * types like \c System.String are exposed as \c MonoString* parameters.   This is
  * different than the way that strings are surfaced in P/Invoke.
  *
  * For more information on how the parameters are marshalled, see the
@@ -8279,11 +8276,10 @@ no_icall_table (void)
 
 /**
  * mono_lookup_internal_call_full:
- * @method: the method to look up
- * @uses_handles: out argument if method needs handles around managed objects.
- *
- * Returns a pointer to the icall code for the given method.  If
- * uses_handles is not NULL, it will be set to TRUE if the method
+ * \param method the method to look up
+ * \param uses_handles out argument if method needs handles around managed objects.
+ * \returns a pointer to the icall code for the given method.  If
+ * \p uses_handles is not NULL, it will be set to TRUE if the method
  * needs managed objects wrapped using the infrastructure in handle.h
  *
  * If the method is not found, warns and returns NULL.
@@ -8412,6 +8408,9 @@ mono_lookup_internal_call_full (MonoMethod *method, mono_bool *uses_handles)
 #endif
 }
 
+/**
+ * mono_lookup_internal_call:
+ */
 gpointer
 mono_lookup_internal_call (MonoMethod *method)
 {