зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1138293 - Remove moz_malloc/moz_free/moz_realloc/moz_calloc. r=njn
We need to use _impl variants within mozalloc.h when they are defined because of how mozglue.dll is linked on Windows, where using malloc/free would use the symbols from the MSVCRT instead of ours.
This commit is contained in:
Родитель
c39e359c7d
Коммит
26b3c4f285
|
@ -574,9 +574,9 @@ class LSANLeaks(object):
|
|||
# Don't various allocation-related stack frames, as they do not help much to
|
||||
# distinguish different leaks.
|
||||
unescapedSkipList = [
|
||||
"malloc", "js_malloc", "malloc_", "__interceptor_malloc", "moz_malloc", "moz_xmalloc",
|
||||
"calloc", "js_calloc", "calloc_", "__interceptor_calloc", "moz_calloc", "moz_xcalloc",
|
||||
"realloc","js_realloc", "realloc_", "__interceptor_realloc", "moz_realloc", "moz_xrealloc",
|
||||
"malloc", "js_malloc", "malloc_", "__interceptor_malloc", "moz_xmalloc",
|
||||
"calloc", "js_calloc", "calloc_", "__interceptor_calloc", "moz_xcalloc",
|
||||
"realloc","js_realloc", "realloc_", "__interceptor_realloc", "moz_xrealloc",
|
||||
"new",
|
||||
"js::MallocProvider",
|
||||
]
|
||||
|
|
|
@ -77,12 +77,6 @@ extern "C" MOZ_MEMORY_API char *strndup_impl(const char *, size_t);
|
|||
#define UNLIKELY(x) (x)
|
||||
#endif
|
||||
|
||||
void
|
||||
moz_free(void* ptr)
|
||||
{
|
||||
free_impl(ptr);
|
||||
}
|
||||
|
||||
void*
|
||||
moz_xmalloc(size_t size)
|
||||
{
|
||||
|
@ -93,11 +87,6 @@ moz_xmalloc(size_t size)
|
|||
}
|
||||
return ptr;
|
||||
}
|
||||
void*
|
||||
moz_malloc(size_t size)
|
||||
{
|
||||
return malloc_impl(size);
|
||||
}
|
||||
|
||||
void*
|
||||
moz_xcalloc(size_t nmemb, size_t size)
|
||||
|
@ -109,11 +98,6 @@ moz_xcalloc(size_t nmemb, size_t size)
|
|||
}
|
||||
return ptr;
|
||||
}
|
||||
void*
|
||||
moz_calloc(size_t nmemb, size_t size)
|
||||
{
|
||||
return calloc_impl(nmemb, size);
|
||||
}
|
||||
|
||||
void*
|
||||
moz_xrealloc(void* ptr, size_t size)
|
||||
|
@ -125,11 +109,6 @@ moz_xrealloc(void* ptr, size_t size)
|
|||
}
|
||||
return newptr;
|
||||
}
|
||||
void*
|
||||
moz_realloc(void* ptr, size_t size)
|
||||
{
|
||||
return realloc_impl(ptr, size);
|
||||
}
|
||||
|
||||
char*
|
||||
moz_xstrdup(const char* str)
|
||||
|
|
|
@ -48,45 +48,42 @@
|
|||
extern "C" {
|
||||
#endif /* ifdef __cplusplus */
|
||||
|
||||
/*
|
||||
* We need to use malloc_impl and free_impl in this file when they are
|
||||
* defined, because of how mozglue.dll is linked on Windows, where using
|
||||
* malloc/free would end up using the symbols from the MSVCRT instead of
|
||||
* ours.
|
||||
*/
|
||||
#ifndef free_impl
|
||||
#define free_impl free
|
||||
#define free_impl_
|
||||
#endif
|
||||
#ifndef malloc_impl
|
||||
#define malloc_impl malloc
|
||||
#define malloc_impl_
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Each pair of declarations below is analogous to a "standard"
|
||||
* allocation function, except that the out-of-memory handling is made
|
||||
* explicit. The |moz_x| versions will never return a NULL pointer;
|
||||
* if memory is exhausted, they abort. The |moz_| versions may return
|
||||
* NULL pointers if memory is exhausted: their return value must be
|
||||
* checked.
|
||||
* Each declaration below is analogous to a "standard" allocation
|
||||
* function, except that the out-of-memory handling is made explicit.
|
||||
* The |moz_x| versions will never return a NULL pointer; if memory
|
||||
* is exhausted, they abort. The |moz_| versions may return NULL
|
||||
* pointers if memory is exhausted: their return value must be checked.
|
||||
*
|
||||
* All these allocation functions are *guaranteed* to return a pointer
|
||||
* to memory allocated in such a way that that memory can be freed by
|
||||
* passing that pointer to |moz_free()|.
|
||||
* passing that pointer to |free()|.
|
||||
*/
|
||||
|
||||
MFBT_API
|
||||
void moz_free(void* ptr);
|
||||
|
||||
MFBT_API void* moz_xmalloc(size_t size)
|
||||
NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
|
||||
|
||||
MFBT_API
|
||||
void* moz_malloc(size_t size)
|
||||
NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
|
||||
|
||||
|
||||
MFBT_API void* moz_xcalloc(size_t nmemb, size_t size)
|
||||
NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
|
||||
|
||||
MFBT_API void* moz_calloc(size_t nmemb, size_t size)
|
||||
NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
|
||||
|
||||
|
||||
MFBT_API void* moz_xrealloc(void* ptr, size_t size)
|
||||
NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
|
||||
|
||||
MFBT_API void* moz_realloc(void* ptr, size_t size)
|
||||
NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
|
||||
|
||||
|
||||
MFBT_API char* moz_xstrdup(const char* str)
|
||||
NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
|
||||
|
||||
|
@ -187,7 +184,7 @@ void* operator new(size_t size) MOZALLOC_THROW_BAD_ALLOC
|
|||
MOZALLOC_EXPORT_NEW MOZALLOC_INLINE
|
||||
void* operator new(size_t size, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
|
||||
{
|
||||
return moz_malloc(size);
|
||||
return malloc_impl(size);
|
||||
}
|
||||
|
||||
MOZALLOC_EXPORT_NEW MOZALLOC_INLINE
|
||||
|
@ -199,31 +196,31 @@ void* operator new[](size_t size) MOZALLOC_THROW_BAD_ALLOC
|
|||
MOZALLOC_EXPORT_NEW MOZALLOC_INLINE
|
||||
void* operator new[](size_t size, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
|
||||
{
|
||||
return moz_malloc(size);
|
||||
return malloc_impl(size);
|
||||
}
|
||||
|
||||
MOZALLOC_EXPORT_NEW MOZALLOC_INLINE
|
||||
void operator delete(void* ptr) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
|
||||
{
|
||||
return moz_free(ptr);
|
||||
return free_impl(ptr);
|
||||
}
|
||||
|
||||
MOZALLOC_EXPORT_NEW MOZALLOC_INLINE
|
||||
void operator delete(void* ptr, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
|
||||
{
|
||||
return moz_free(ptr);
|
||||
return free_impl(ptr);
|
||||
}
|
||||
|
||||
MOZALLOC_EXPORT_NEW MOZALLOC_INLINE
|
||||
void operator delete[](void* ptr) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
|
||||
{
|
||||
return moz_free(ptr);
|
||||
return free_impl(ptr);
|
||||
}
|
||||
|
||||
MOZALLOC_EXPORT_NEW MOZALLOC_INLINE
|
||||
void operator delete[](void* ptr, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
|
||||
{
|
||||
return moz_free(ptr);
|
||||
return free_impl(ptr);
|
||||
}
|
||||
|
||||
|
||||
|
@ -249,32 +246,32 @@ void operator delete[](void* ptr, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_E
|
|||
MOZALLOC_INLINE
|
||||
void* operator new(size_t size, const mozilla::fallible_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
|
||||
{
|
||||
return moz_malloc(size);
|
||||
return malloc_impl(size);
|
||||
}
|
||||
|
||||
MOZALLOC_INLINE
|
||||
void* operator new[](size_t size, const mozilla::fallible_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
|
||||
{
|
||||
return moz_malloc(size);
|
||||
return malloc_impl(size);
|
||||
}
|
||||
|
||||
MOZALLOC_INLINE
|
||||
void operator delete(void* ptr, const mozilla::fallible_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
|
||||
{
|
||||
moz_free(ptr);
|
||||
free_impl(ptr);
|
||||
}
|
||||
|
||||
MOZALLOC_INLINE
|
||||
void operator delete[](void* ptr, const mozilla::fallible_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
|
||||
{
|
||||
moz_free(ptr);
|
||||
free_impl(ptr);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This policy is identical to MallocAllocPolicy, except it uses
|
||||
* moz_xmalloc/moz_xcalloc/moz_xrealloc/moz_free instead of
|
||||
* malloc/calloc/realloc/free.
|
||||
* moz_xmalloc/moz_xcalloc/moz_xrealloc instead of
|
||||
* malloc/calloc/realloc.
|
||||
*/
|
||||
class InfallibleAllocPolicy
|
||||
{
|
||||
|
@ -305,7 +302,7 @@ public:
|
|||
|
||||
void free_(void* aPtr)
|
||||
{
|
||||
moz_free(aPtr);
|
||||
free_impl(aPtr);
|
||||
}
|
||||
|
||||
void reportAllocOverflow() const
|
||||
|
@ -315,4 +312,13 @@ public:
|
|||
|
||||
#endif /* ifdef __cplusplus */
|
||||
|
||||
#ifdef malloc_impl_
|
||||
#undef malloc_impl_
|
||||
#undef malloc_impl
|
||||
#endif
|
||||
#ifdef free_impl_
|
||||
#undef free_impl_
|
||||
#undef free_impl
|
||||
#endif
|
||||
|
||||
#endif /* ifndef mozilla_mozalloc_h */
|
||||
|
|
Загрузка…
Ссылка в новой задаче