зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 8a4050c7e0fd (bug 1423114) for bustages on memory/mozalloc/mozalloc.cpp r=backout on a CLOSED TREE
This commit is contained in:
Родитель
a2bc85549d
Коммит
dfd58840d1
|
@ -40,18 +40,20 @@ MOZ_MEMORY_API char *strndup_impl(const char *, size_t);
|
|||
// we need not to use the suffixes.
|
||||
|
||||
#if defined(MALLOC_H)
|
||||
# include MALLOC_H // for memalign, malloc_size, malloc_us
|
||||
# include MALLOC_H // for memalign, valloc, malloc_size, malloc_us
|
||||
#endif // if defined(MALLOC_H)
|
||||
#include <stdlib.h> // for malloc, free
|
||||
#if defined(XP_UNIX)
|
||||
# include <unistd.h>
|
||||
# include <unistd.h> // for valloc on *BSD
|
||||
#endif //if defined(XP_UNIX)
|
||||
|
||||
#define malloc_impl malloc
|
||||
#define posix_memalign_impl posix_memalign
|
||||
#define calloc_impl calloc
|
||||
#define realloc_impl realloc
|
||||
#define free_impl free
|
||||
#define memalign_impl memalign
|
||||
#define valloc_impl valloc
|
||||
#define malloc_usable_size_impl malloc_usable_size
|
||||
#define strdup_impl strdup
|
||||
#define strndup_impl strndup
|
||||
|
@ -133,6 +135,21 @@ moz_xstrndup(const char* str, size_t strsize)
|
|||
}
|
||||
#endif // if defined(HAVE_STRNDUP)
|
||||
|
||||
#if defined(HAVE_POSIX_MEMALIGN)
|
||||
int
|
||||
moz_xposix_memalign(void **ptr, size_t alignment, size_t size)
|
||||
{
|
||||
int err = posix_memalign_impl(ptr, alignment, size);
|
||||
if (UNLIKELY(err && ENOMEM == err)) {
|
||||
mozalloc_handle_oom(size);
|
||||
return moz_xposix_memalign(ptr, alignment, size);
|
||||
}
|
||||
// else: (0 == err) or (EINVAL == err)
|
||||
return err;
|
||||
}
|
||||
#endif // if defined(HAVE_POSIX_MEMALIGN)
|
||||
|
||||
#if defined(HAVE_MEMALIGN)
|
||||
void*
|
||||
moz_xmemalign(size_t boundary, size_t size)
|
||||
{
|
||||
|
@ -144,6 +161,20 @@ moz_xmemalign(size_t boundary, size_t size)
|
|||
// non-NULL ptr or errno == EINVAL
|
||||
return ptr;
|
||||
}
|
||||
#endif // if defined(HAVE_MEMALIGN)
|
||||
|
||||
#if defined(HAVE_VALLOC)
|
||||
void*
|
||||
moz_xvalloc(size_t size)
|
||||
{
|
||||
void* ptr = valloc_impl(size);
|
||||
if (UNLIKELY(!ptr)) {
|
||||
mozalloc_handle_oom(size);
|
||||
return moz_xvalloc(size);
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
#endif // if defined(HAVE_VALLOC)
|
||||
|
||||
#ifndef MOZ_STATIC_RUNTIME
|
||||
size_t
|
||||
|
|
|
@ -97,8 +97,24 @@ MFBT_API char* moz_xstrndup(const char* str, size_t strsize)
|
|||
MOZ_ALLOCATOR;
|
||||
#endif /* if defined(HAVE_STRNDUP) */
|
||||
|
||||
|
||||
#if defined(HAVE_POSIX_MEMALIGN)
|
||||
MFBT_API MOZ_MUST_USE
|
||||
int moz_xposix_memalign(void **ptr, size_t alignment, size_t size);
|
||||
#endif /* if defined(HAVE_POSIX_MEMALIGN) */
|
||||
|
||||
|
||||
#if defined(HAVE_MEMALIGN)
|
||||
MFBT_API void* moz_xmemalign(size_t boundary, size_t size)
|
||||
MOZ_ALLOCATOR;
|
||||
#endif /* if defined(HAVE_MEMALIGN) */
|
||||
|
||||
|
||||
#if defined(HAVE_VALLOC)
|
||||
MFBT_API void* moz_xvalloc(size_t size)
|
||||
MOZ_ALLOCATOR;
|
||||
#endif /* if defined(HAVE_VALLOC) */
|
||||
|
||||
|
||||
MOZ_END_EXTERN_C
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ allocatorFns = [
|
|||
'calloc',
|
||||
# Matches realloc, replace_realloc, moz_xrealloc, vpx_realloc, js_realloc, pod_realloc, pod_reallocCanGC.
|
||||
'realloc',
|
||||
# Matches memalign, posix_memalign, replace_memalign, replace_posix_memalign, moz_xmemalign, vpx_memalign, malloc_zone_memalign.
|
||||
# Matches memalign, posix_memalign, replace_memalign, replace_posix_memalign, moz_xmemalign, moz_xposix_memalign, vpx_memalign, malloc_zone_memalign.
|
||||
'memalign',
|
||||
'operator new(',
|
||||
'operator new[](',
|
||||
|
|
Загрузка…
Ссылка в новой задаче