-/*
- * mono-perfcounters.c
+/**
+ * \file
*
* Performance counters support.
*
return TRUE;
}
+/* this is an icall */
MonoString*
mono_perfcounter_category_help (MonoString *category, MonoString *machine)
{
+ MonoError error;
+ MonoString *result = NULL;
const CategoryDesc *cdesc;
+ error_init (&error);
/* no support for counters on other machines */
if (mono_string_compare_ascii (machine, "."))
return NULL;
SharedCategory *scat = find_custom_category (category);
if (!scat)
return NULL;
- return mono_string_new (mono_domain_get (), custom_category_help (scat));
+ result = mono_string_new_checked (mono_domain_get (), custom_category_help (scat), &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
+ return result;
}
- return mono_string_new (mono_domain_get (), cdesc->help);
+ result = mono_string_new_checked (mono_domain_get (), cdesc->help, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
+ return result;
}
/*
return FALSE;
}
+/* this is an icall */
MonoArray*
mono_perfcounter_category_names (MonoString *machine)
{
for (i = 0; i < NUM_CATEGORIES; ++i) {
const CategoryDesc *cdesc = &predef_categories [i];
- mono_array_setref (res, i, mono_string_new (domain, cdesc->name));
+ MonoString *name = mono_string_new_checked (domain, cdesc->name, &error);
+ if (!is_ok (&error))
+ goto leave;
+ mono_array_setref (res, i, name);
}
for (tmp = custom_categories; tmp; tmp = tmp->next) {
SharedCategory *scat = (SharedCategory *)tmp->data;
- mono_array_setref (res, i, mono_string_new (domain, scat->name));
+ MonoString *name = mono_string_new_checked (domain, scat->name, &error);
+ if (!is_ok (&error))
+ goto leave;
+ mono_array_setref (res, i, name);
i++;
}
+leave:
perfctr_unlock ();
g_slist_free (custom_categories);
+ mono_error_set_pending_exception (&error);
return res;
}
return NULL;
for (i = cdesc->first_counter; i < cdesc [1].first_counter; ++i) {
const CounterDesc *desc = &predef_counters [i];
- mono_array_setref (res, i - cdesc->first_counter, mono_string_new (domain, desc->name));
+ MonoString *name = mono_string_new_checked (domain, desc->name, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
+ mono_array_setref (res, i - cdesc->first_counter, name);
}
return res;
}
}
for (i = 0; i < scat->num_counters; ++i) {
- mono_array_setref (res, i, mono_string_new (domain, p + 1));
+ MonoString *str = mono_string_new_checked (domain, p + 1, &error);
+ if (!is_ok (&error))
+ goto leave;
+ mono_array_setref (res, i, str);
p += 2; /* skip counter type */
p += strlen (p) + 1; /* skip counter name */
p += strlen (p) + 1; /* skip counter help */
}
- perfctr_unlock ();
- return res;
- }
+ } else
+ res = mono_array_new_checked (domain, mono_get_string_class (), 0, &error);
+leave:
perfctr_unlock ();
- res = mono_array_new_checked (domain, mono_get_string_class (), 0, &error);
mono_error_set_pending_exception (&error);
return res;
}
sprintf (buf, "%d", GPOINTER_TO_INT (array [i]));
p = buf;
}
- mono_array_setref (res, i, mono_string_new (domain, p));
+ MonoString *str = mono_string_new_checked (domain, p, error);
if (p != buf)
g_free (p);
+ return_val_if_nok (error, NULL);
+ mono_array_setref (res, i, str);
}
return res;
}
return_val_if_nok (error, NULL);
for (i = 0; i < count; ++i) {
char* p = (char *)array[i];
- mono_array_setref (res, i, mono_string_new (domain, p));
+ MonoString *str = mono_string_new_checked (domain, p, error);
+ return_val_if_nok (error, NULL);
+ mono_array_setref (res, i, str);
}
return res;
buf [i] = GINT_TO_POINTER (i - 1); /* -1 => _Total */
array = get_string_array (buf, count, FALSE, error);
g_free (buf);
- mono_array_setref (array, 0, mono_string_new (mono_domain_get (), "_Total"));
+ MonoString *total = mono_string_new_checked (mono_domain_get (), "_Total", error);
+ return_val_if_nok (error, NULL);
+ mono_array_setref (array, 0, total);
return array;
}
}
for (tmp = list; tmp; tmp = tmp->next) {
SharedInstance *inst = (SharedInstance *)tmp->data;
- mono_array_setref (array, i, mono_string_new (mono_domain_get (), inst->instance_name));
+ MonoString *str = mono_string_new_checked (mono_domain_get (), inst->instance_name, error);
+ if (!is_ok (error)) {
+ g_slist_free (list);
+ return NULL;
+ }
+ mono_array_setref (array, i, str);
i++;
}
g_slist_free (list);