Core/StackArray: Moved StackArray class to its own header

This commit is contained in:
Jérôme Leclercq
2018-07-02 17:53:49 +02:00
parent bb0456ffed
commit 2fcea6b79f
11 changed files with 318 additions and 271 deletions

View File

@@ -5,7 +5,7 @@
#include <Nazara/Core/Posix/DirectoryImpl.hpp>
#include <Nazara/Core/Directory.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Core/MemoryHelper.hpp>
#include <Nazara/Core/StackArray.hpp>
#include <Nazara/Core/String.hpp>
#include <cstring>
#include <errno.h>
@@ -39,7 +39,7 @@ namespace Nz
std::size_t resultNameSize = std::strlen(m_result->d_name);
std::size_t fullNameSize = pathSize + 1 + resultNameSize;
StackArray<char> fullName = NazaraStackAllocationNoInit(char, fullNameSize + 1);
StackArray<char> fullName = NazaraStackArrayNoInit(char, fullNameSize + 1);
std::memcpy(&fullName[0], path.GetConstBuffer(), pathSize * sizeof(char));
fullName[pathSize] = '/';
std::memcpy(&fullName[pathSize + 1], m_result->d_name, resultNameSize * sizeof(char));

View File

@@ -4,7 +4,7 @@
#include <Nazara/Network/Posix/SocketImpl.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Core/MemoryHelper.hpp>
#include <Nazara/Core/StackArray.hpp>
#include <Nazara/Network/NetBuffer.hpp>
#include <Nazara/Network/Posix/IpAddressImpl.hpp>
#include <netinet/tcp.h>
@@ -574,7 +574,7 @@ namespace Nz
NazaraAssert(handle != InvalidHandle, "Invalid handle");
NazaraAssert(buffers && bufferCount > 0, "Invalid buffers");
StackArray<iovec> sysBuffers = NazaraStackAllocation(iovec, bufferCount);
StackArray<iovec> sysBuffers = NazaraStackArray(iovec, bufferCount);
for (std::size_t i = 0; i < bufferCount; ++i)
{
sysBuffers[i].iov_base = buffers[i].data;
@@ -698,7 +698,7 @@ namespace Nz
NazaraAssert(handle != InvalidHandle, "Invalid handle");
NazaraAssert(buffers && bufferCount > 0, "Invalid buffers");
StackArray<iovec> sysBuffers = NazaraStackAllocation(iovec, bufferCount);
StackArray<iovec> sysBuffers = NazaraStackArray(iovec, bufferCount);
for (std::size_t i = 0; i < bufferCount; ++i)
{
sysBuffers[i].iov_base = buffers[i].data;

View File

@@ -5,7 +5,7 @@
#include <Nazara/Network/Win32/SocketImpl.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Core/Log.hpp>
#include <Nazara/Core/MemoryHelper.hpp>
#include <Nazara/Core/StackArray.hpp>
#include <Nazara/Network/Win32/IpAddressImpl.hpp>
// Some compilers (older versions of MinGW) lack Mstcpip.h which defines some structs/defines
@@ -615,7 +615,7 @@ namespace Nz
IpAddress senderIp;
StackArray<WSABUF> winBuffers = NazaraStackAllocation(WSABUF, bufferCount);
StackArray<WSABUF> winBuffers = NazaraStackArray(WSABUF, bufferCount);
for (std::size_t i = 0; i < bufferCount; ++i)
{
winBuffers[i].buf = static_cast<CHAR*>(buffers[i].data);
@@ -714,7 +714,7 @@ namespace Nz
IpAddressImpl::SockAddrBuffer nameBuffer;
int bufferLength = IpAddressImpl::ToSockAddr(to, nameBuffer.data());
StackArray<WSABUF> winBuffers = NazaraStackAllocation(WSABUF, bufferCount);
StackArray<WSABUF> winBuffers = NazaraStackArray(WSABUF, bufferCount);
for (std::size_t i = 0; i < bufferCount; ++i)
{
winBuffers[i].buf = static_cast<CHAR*>(buffers[i].data);

View File

@@ -3,7 +3,7 @@
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Physics2D/PhysWorld2D.hpp>
#include <Nazara/Core/MemoryHelper.hpp>
#include <Nazara/Core/StackArray.hpp>
#include <chipmunk/chipmunk.h>
#include <Nazara/Physics2D/Debug.hpp>
@@ -44,7 +44,7 @@ namespace Nz
{
//TODO: constexpr if to prevent copy/cast if sizeof(cpVect) == sizeof(Vector2f)
StackArray<Vector2f> nVertices = NazaraStackAllocation(Vector2f, vertexCount);
StackArray<Vector2f> nVertices = NazaraStackArray(Vector2f, vertexCount);
for (int i = 0; i < vertexCount; ++i)
nVertices[i].Set(float(vertices[i].x), float(vertices[i].y));

View File

@@ -3,7 +3,7 @@
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Physics3D/PhysWorld3D.hpp>
#include <Nazara/Core/MemoryHelper.hpp>
#include <Nazara/Core/StackArray.hpp>
#include <Newton/Newton.h>
#include <cassert>
#include <Nazara/Physics3D/Debug.hpp>
@@ -173,7 +173,7 @@ namespace Nz
using ContactJoint = void*;
// Query all joints first, to prevent removing a joint from the list while iterating on it
StackArray<ContactJoint> contacts = NazaraStackAllocationNoInit(ContactJoint, NewtonContactJointGetContactCount(contactJoint));
StackArray<ContactJoint> contacts = NazaraStackArray(ContactJoint, NewtonContactJointGetContactCount(contactJoint));
std::size_t contactIndex = 0;
for (ContactJoint contact = NewtonContactJointGetFirstContact(contactJoint); contact; contact = NewtonContactJointGetNextContact(contactJoint, contact))
{

View File

@@ -8,8 +8,8 @@
#include <Nazara/Core/Error.hpp>
#include <Nazara/Core/ErrorFlags.hpp>
#include <Nazara/Core/Log.hpp>
#include <Nazara/Core/MemoryHelper.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Core/StackArray.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/Context.hpp>
#include <Nazara/Renderer/DebugDrawer.hpp>
@@ -1762,7 +1762,7 @@ namespace Nz
glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxLength);
maxLength++;
StackArray<GLchar> nameBuffer = NazaraStackAllocation(GLchar, maxLength + 1);
StackArray<GLchar> nameBuffer = NazaraStackArray(GLchar, maxLength + 1);
for (GLint i = 0; i < count; i++)
{
GLint size;