[MonoError] Add MonoErrorBoxed for mempool-stored errors.
authorAleksey Kliger <aleksey@xamarin.com>
Thu, 29 Sep 2016 21:15:48 +0000 (17:15 -0400)
committerAleksey Kliger <aleksey@xamarin.com>
Tue, 4 Oct 2016 15:21:53 +0000 (11:21 -0400)
commit139283728831f300605f63f8b9f087d5ed701a80
treebc60efb5806140dda34a867b21971508a5354d8a
parent633af27d6800a6a5c050c9e4c50a0d8b67c97c20
[MonoError] Add MonoErrorBoxed for mempool-stored errors.

The usual MonoError is suitable as a short-lived stack-allocated error
with a lifetime confined to a function call.
Internally it performs allocations using g_malloc/g_free.

The MonoErrorBoxed is a mempool-allocated error whose lifetime is tied
to the lifetime of a MonoImage.

We provide two operations:

1. MonoErrorBoxed* mono_error_box (MonoError *ierror, MonoImage *image);

  Creates a new boxed error in the given mempool from MonoError.
  It does not alter ierror, so you still have to clean it up with
  mono_error_cleanup or mono_error_convert_to_exception or another such function.

2.   gboolean mono_error_set_from_boxed (MonoError *oerror, MonoErrorBoxed *from_box);

  Sets the error condition in the oerror from the contents of the given
  boxed error.  Does not alter the boxed error, so it can be used in a
  future call to mono_error_set_from_boxed as needed.  The oerror
  should've been previously initialized with mono_error_init, as usual.
mono/utils/mono-error-internals.h
mono/utils/mono-error.c
mono/utils/mono-error.h