On Tuesday, March 31, 2015 at 9:00:01 AM UTC+3, Mike Hommey wrote:
> Hi,
> 
> In the next few weeks, there is going to be a reduction in the number of
> our memory allocator wrappers/functions, for essentially the following
> reasons:
> - we have too many of them,
> - developers rarely know which one to use, which results in:
> - developers often make mistakes[1]
> 
> This started today with the landing of bug 1138293, which effectively
> removed moz_malloc, moz_realloc, moz_calloc and moz_free.
> 
> They were replaced, respectively, with malloc, realloc, calloc and free,
> because that works(tm).
> 
> If you have pending patches that use moz_malloc, moz_realloc,
> moz_calloc, moz_free, you can just remove the moz_ prefix.
> 
> The infallible moz_xmalloc, moz_xrealloc and moz_xcalloc still do exist,
> and memory allocated with them can be freed with free.
> 
> With that being said, please refrain from using any of the functions
> mentioned above. Please prefer the C++y new and delete. new is
> infallible by default (equivalent to moz_xmalloc). If you need an
> equivalent to moz_malloc, use fallible new instead:
> 
>         new (fallible) Foo()
> 
> Please note that this shouldn't make uplifting harder. Platform patches
> using malloc/free/new/delete should apply and work just fine on beta,
> aurora and esr (with a few exceptions ; if you uplift something from
> mfbt/mozglue that uses the memory allocator, please check with me).
> 
> Cheers,
> 
> Mike
> 
> 
> 1. if you look for it, you'll find cases of one family used for
>    allocation and another for deallocation, for possibly close to all
>    combinations of families (NS_Alloc, nsMemory, moz_malloc, malloc,
>    new).


Just pointing out that the removal of these methods might break proprietary 
code. Actually, it breaks "libqc_b2g_ril.so"

>Failed to load native module at path 
>'/system/b2g/distribution/bundles/libqc_b2g_ril/libqc_b2g_ril.so': (80004005) 
>dlopen failed: cannot locate symbol "moz_free" referenced by 
>"libqc_b2g_ril.so"...
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to