forked from mirrors/gecko-dev
Bug 1402647 - Add a memalign implementation on platforms that don't have one. r=njn
--HG-- extra : rebase_source : bf1ff9da4c4647f5e930194d0d008466f0b2b593
This commit is contained in:
parent
d7703e388f
commit
77ff4db6d7
1 changed files with 19 additions and 0 deletions
|
|
@ -8,6 +8,25 @@
|
||||||
#include "mozjemalloc.h"
|
#include "mozjemalloc.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#ifndef HAVE_MEMALIGN
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
inline void* memalign(size_t aAlignment, size_t aSize)
|
||||||
|
{
|
||||||
|
#ifdef XP_WIN
|
||||||
|
return _aligned_malloc(aSize, aAlignment);
|
||||||
|
#else
|
||||||
|
void* ret;
|
||||||
|
if (posix_memalign(&ret, aAlignment, aSize) != 0) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
struct SystemMalloc {
|
struct SystemMalloc {
|
||||||
#define MALLOC_DECL(name, return_type, ...) \
|
#define MALLOC_DECL(name, return_type, ...) \
|
||||||
static inline return_type \
|
static inline return_type \
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue