[Mono-dev] [PATCH] Adding hooks for BSTR Marshaling

Bill Holmes billholmes54 at gmail.com
Thu May 28 13:49:22 EDT 2009


Hi,

I have added and attached the work mentioned in my original dealing
with Marshal.AllocCoTaskMem and  Marshal.AllocHGlobal.

The problem I am trying to solve is the same as before.  Our
application expects to use its own allocator for these calls, not
g_malloc and g_free.

monomarshalhooks5.patch contains all the changes for BSTR, CoTaskMem
and HGlobal, but I will commit the BSTR fix first and then other
allocator changes second.

-bill

2009-05-28  Bill Holmes  <billholmes54 at gmail.com>

	* marshal-hooks.h : Adding declaration for
	  mono_install_alloc_hglobal_funcs and mono_install_alloc_cotaskmem_funcs.

	* marshal.c : Adding mono_install_alloc_hglobal_funcs to override alloc,
	  realloc and free functions for HGlobal

	* marshal.c : Adding mono_install_alloc_cotaskmem_funcs to override alloc,
	  realloc and free functions for CoTaskMem

	Code is contributed under MIT/X11 license.

On Fri, May 22, 2009 at 12:15 PM, Bill Holmes <billholmes54 at gmail.com> wrote:
> Hi,
>
> The attached patch allows hook functions to be registered with mono to
> use when marshaling BSTRs.  I need this functionality because the
> Win32 API emulator we use requires that the encoding is ucs4 and
> another allocator be used.
>
> This patch only correct part of my problem.  If this is approved I
> will be adding similar code for Marshal.AllocCoTaskMem and
> Marshal.AllocHGlobal, which will be a separate commit.
>
> 2009-05-22  Bill Holmes  <billholmes54 at gmail.com>
>
>        * cominterop.c : mono_string_to_bstr, mono_string_from_bstr and
>          mono_free_bstr changed to call external hooks if installed.
>          mono_install_bstr_funcs added to the set the hooks.
>
>        * marshal-hooks.h : Added to declare mono_install_bstr_funcs
>
>        * Makefile.am : Adding marshal-hooks.h to the list of public API
>          header files.
>
>        Code is contributed under MIT/X11 license.
>
> -bill
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: monocomstring_new4.patch
Type: application/octet-stream
Size: 4397 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20090528/214805c0/attachment-0002.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: monomarshalhooks5.patch
Type: application/octet-stream
Size: 10058 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20090528/214805c0/attachment-0003.obj 


More information about the Mono-devel-list mailing list