Core/MemoryHelper: Fix alloca with a size equivalent to zero

This commit is contained in:
Jérôme Leclercq 2018-01-05 15:40:25 +01:00
parent 4b6d7d2e47
commit 1e53274623
1 changed files with 4 additions and 1 deletions

View File

@ -1,4 +1,4 @@
// Copyright (C) 2017 Jérôme Leclercq
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
@ -11,6 +11,7 @@
#include <malloc.h>
// with MSVC, using alloca with a size of zero returns a valid pointer
#define NAZARA_ALLOCA(size) _alloca(size)
#define NAZARA_ALLOCA_SUPPORT
@ -18,6 +19,8 @@
#include <alloca.h>
#define NAZARA_ALLOCA(size) alloca(size)
// with Clang/GCC, using alloca with a size of zero does nothing good
#define NAZARA_ALLOCA(size) alloca(((size) > 0) ? (size) : 1)
#define NAZARA_ALLOCA_SUPPORT
#endif