Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Utils/GridData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <openvdb/Types.h>

#include "Memory.hpp"
#include "typeindex"
#include <typeindex>

namespace HNS {

Expand Down
13 changes: 9 additions & 4 deletions src/Utils/Memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@
#include <malloc.h>
#define _aligned_malloc(size, alignment) memalign(alignment, size)
#define _aligned_free free
#elif _WIN32
#elif defined(_WIN32)
#include <malloc.h>
#define _aligned_malloc(size, alignment) _aligned_malloc(size, alignment)
#define _aligned_free _aligned_free
/* Windows provides _aligned_malloc and _aligned_free */
#else

#include <cstdlib>
static inline void* _aligned_malloc(size_t size, size_t alignment) {
void* ptr = nullptr;
if (posix_memalign(&ptr, alignment, size) != 0) return nullptr;
return ptr;
}
static inline void _aligned_free(void* ptr) { free(ptr); }
#endif

enum class AllocationType { Standard, Aligned, CudaPinned };
Expand Down