From 896c610b7205cc15a40fc5c8e80e70fb377c9357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Sat, 21 Dec 2024 19:24:50 -0800 Subject: [PATCH] Removing alloca compat include. --- examples/14-shadowvolumes/shadowvolumes.cpp | 2 +- examples/23-vectordisplay/vectordisplay.cpp | 6 +++--- examples/common/debugdraw/debugdraw.cpp | 2 +- examples/common/example-glue.cpp | 2 +- src/bgfx.cpp | 8 ++++---- src/bgfx_p.h | 6 +++--- src/debug_renderdoc.cpp | 2 +- src/renderer_d3d11.cpp | 4 ++-- src/renderer_d3d12.cpp | 8 ++++---- src/renderer_gl.cpp | 12 ++++++------ tools/shaderc/shaderc.cpp | 8 ++++---- 11 files changed, 30 insertions(+), 30 deletions(-) diff --git a/examples/14-shadowvolumes/shadowvolumes.cpp b/examples/14-shadowvolumes/shadowvolumes.cpp index 4ccea3a9399..8cb3bc7a9fc 100644 --- a/examples/14-shadowvolumes/shadowvolumes.cpp +++ b/examples/14-shadowvolumes/shadowvolumes.cpp @@ -707,7 +707,7 @@ uint16_t weldVertices(WeldedVertex* _output, const bgfx::VertexLayout& _layout, uint16_t numVertices = 0; const uint32_t size = sizeof(uint16_t)*(hashSize + _num); - uint16_t* hashTable = (uint16_t*)alloca(size); + uint16_t* hashTable = (uint16_t*)BX_STACK_ALLOC(size); bx::memSet(hashTable, 0xff, size); uint16_t* next = hashTable + hashSize; diff --git a/examples/23-vectordisplay/vectordisplay.cpp b/examples/23-vectordisplay/vectordisplay.cpp index 3b18a98bd54..6ece80366d0 100644 --- a/examples/23-vectordisplay/vectordisplay.cpp +++ b/examples/23-vectordisplay/vectordisplay.cpp @@ -339,7 +339,7 @@ void VectorDisplay::endDraw() // from the list of points, build a list of lines uint32_t nlines = (uint32_t)m_pendingPoints.size() - 1; - Line* lines = (Line*)alloca(nlines * sizeof(Line) ); + Line* lines = (Line*)BX_STACK_ALLOC(nlines * sizeof(Line) ); float t = effectiveThickness(); int first_last_same = true @@ -630,7 +630,7 @@ void VectorDisplay::drawFan(float _cx, float _cy, float _pa, float _a, float _t, { _t = -_t; nsteps = (int32_t)bx::max(1.0f, bx::round(a2pa / (bx::kPi / 8.0f) ) ); - angles = (float*)alloca(sizeof(float) * (nsteps + 1) ); + angles = (float*)BX_STACK_ALLOC(sizeof(float) * (nsteps + 1) ); for (i = 0; i <= nsteps; i++) { angles[i] = _a + i * a2pa / nsteps; @@ -639,7 +639,7 @@ void VectorDisplay::drawFan(float _cx, float _cy, float _pa, float _a, float _t, else { nsteps = (int32_t)bx::max(1.0f, bx::round(pa2a / (bx::kPi / 8.0f) ) ); - angles = (float*)alloca(sizeof(float) * (nsteps + 1) ); + angles = (float*)BX_STACK_ALLOC(sizeof(float) * (nsteps + 1) ); for (i = 0; i <= nsteps; i++) { angles[i] = _pa + i * pa2a / nsteps; diff --git a/examples/common/debugdraw/debugdraw.cpp b/examples/common/debugdraw/debugdraw.cpp index 8327bdba879..9dcc75e7892 100644 --- a/examples/common/debugdraw/debugdraw.cpp +++ b/examples/common/debugdraw/debugdraw.cpp @@ -1169,7 +1169,7 @@ struct DebugDrawEncoderImpl } else { - mtx = (float*)alloca(_num*64); + mtx = (float*)BX_STACK_ALLOC(_num*64); for (uint16_t ii = 0; ii < _num; ++ii) { const float* mtxTransform = (const float*)_mtx; diff --git a/examples/common/example-glue.cpp b/examples/common/example-glue.cpp index a0539bcd029..eab0a9f29d3 100644 --- a/examples/common/example-glue.cpp +++ b/examples/common/example-glue.cpp @@ -176,7 +176,7 @@ void showExampleDialog(entry::AppI* _app, const char* _errorText) { uint32_t num = entry::getNumApps(); - const char** items = (const char**)alloca(num*sizeof(void*) ); + const char** items = (const char**)BX_STACK_ALLOC(num*sizeof(void*) ); uint32_t ii = 0; int32_t current = 0; diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 64090cb68ae..236bce15a08 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -97,7 +97,7 @@ namespace bgfx va_end(argListCopy); if ( (int32_t)sizeof(temp) < total) { - out = (char*)alloca(total+1); + out = (char*)BX_STACK_ALLOC(total+1); bx::memCopy(out, temp, len); bx::vsnprintf(out + len, total-len, _format, _argList); } @@ -136,7 +136,7 @@ namespace bgfx BX_UNUSED(_filePath, _width, _height, _pitch, _data, _size, _yflip); const int32_t len = bx::strLen(_filePath)+5; - char* filePath = (char*)alloca(len); + char* filePath = (char*)BX_STACK_ALLOC(len); bx::strCopy(filePath, len, _filePath); bx::strCat(filePath, len, ".tga"); @@ -447,7 +447,7 @@ namespace bgfx int32_t len = bx::vsnprintf(out, sizeof(temp), _format, argList); if ( (int32_t)sizeof(temp) < len) { - out = (char*)alloca(len+1); + out = (char*)BX_STACK_ALLOC(len+1); len = bx::vsnprintf(out, len, _format, argList); } out[len] = '\0'; @@ -642,7 +642,7 @@ namespace bgfx va_list argListCopy; va_copy(argListCopy, _argList); uint32_t num = bx::vsnprintf(NULL, 0, _format, argListCopy) + 1; - char* temp = (char*)alloca(num); + char* temp = (char*)BX_STACK_ALLOC(num); va_copy(argListCopy, _argList); num = bx::vsnprintf(temp, num, _format, argListCopy); diff --git a/src/bgfx_p.h b/src/bgfx_p.h index c07bf9ef0f2..2b95efe3590 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -787,8 +787,8 @@ namespace bgfx { if (0 < m_num) { - uint32_t* tempKeys = (uint32_t*)alloca(sizeof(m_keys) ); - uint32_t* tempValues = (uint32_t*)alloca(sizeof(m_values) ); + uint32_t* tempKeys = (uint32_t*)BX_STACK_ALLOC(sizeof(m_keys) ); + uint32_t* tempValues = (uint32_t*)BX_STACK_ALLOC(sizeof(m_values) ); bx::radixSort(m_keys, tempKeys, m_values, tempValues, m_num); return true; } @@ -4193,7 +4193,7 @@ namespace bgfx sr.m_num = 0; sr.m_uniforms = NULL; - UniformHandle* uniforms = (UniformHandle*)alloca(count*sizeof(UniformHandle) ); + UniformHandle* uniforms = (UniformHandle*)BX_STACK_ALLOC(count*sizeof(UniformHandle) ); for (uint32_t ii = 0; ii < count; ++ii) { diff --git a/src/debug_renderdoc.cpp b/src/debug_renderdoc.cpp index c04b9537a3f..73af51c6da0 100644 --- a/src/debug_renderdoc.cpp +++ b/src/debug_renderdoc.cpp @@ -31,7 +31,7 @@ namespace bgfx ); if (0 != result) { - HMODULE* modules = (HMODULE*)alloca(size); + HMODULE* modules = (HMODULE*)BX_STACK_ALLOC(size); result = EnumProcessModules(process , modules , size diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index 3cd5437a83a..cf78f3cbdab 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -2089,7 +2089,7 @@ namespace bgfx { namespace d3d11 if (BX_ENABLED(BGFX_CONFIG_DEBUG_ANNOTATION) ) { uint32_t size = _len*sizeof(wchar_t); - wchar_t* name = (wchar_t*)alloca(size+2); + wchar_t* name = (wchar_t*)BX_STACK_ALLOC(size+2); name[_len] = L'\0'; mbstowcs(name, _marker, _len); PIX_SETMARKER(kColorMarker, name); @@ -4420,7 +4420,7 @@ namespace bgfx { namespace d3d11 const uint16_t numSides = ti.numLayers * (imageContainer.m_cubeMap ? 6 : 1); const uint32_t numSrd = numSides * ti.numMips; - D3D11_SUBRESOURCE_DATA* srd = (D3D11_SUBRESOURCE_DATA*)alloca(numSrd*sizeof(D3D11_SUBRESOURCE_DATA) ); + D3D11_SUBRESOURCE_DATA* srd = (D3D11_SUBRESOURCE_DATA*)BX_STACK_ALLOC(numSrd*sizeof(D3D11_SUBRESOURCE_DATA) ); uint32_t kk = 0; diff --git a/src/renderer_d3d12.cpp b/src/renderer_d3d12.cpp index f627c681ada..53e55230518 100644 --- a/src/renderer_d3d12.cpp +++ b/src/renderer_d3d12.cpp @@ -606,7 +606,7 @@ namespace bgfx { namespace d3d12 va_end(argList); temp[size] = '\0'; - wchar_t* wtemp = (wchar_t*)alloca( (size+1)*2); + wchar_t* wtemp = (wchar_t*)BX_STACK_ALLOC( (size+1)*2); mbstowcs(wtemp, temp, size+1); _object->SetName(wtemp); } @@ -5083,7 +5083,7 @@ namespace bgfx { namespace d3d12 m_numMips = ti.numMips; const uint16_t numSides = ti.numLayers * (imageContainer.m_cubeMap ? 6 : 1); const uint32_t numSrd = numSides * ti.numMips; - D3D12_SUBRESOURCE_DATA* srd = (D3D12_SUBRESOURCE_DATA*)alloca(numSrd*sizeof(D3D12_SUBRESOURCE_DATA) ); + D3D12_SUBRESOURCE_DATA* srd = (D3D12_SUBRESOURCE_DATA*)BX_STACK_ALLOC(numSrd*sizeof(D3D12_SUBRESOURCE_DATA) ); uint32_t kk = 0; @@ -5224,7 +5224,7 @@ namespace bgfx { namespace d3d12 state |= D3D12_RESOURCE_STATE_DEPTH_WRITE; state &= ~D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; - clearValue = (D3D12_CLEAR_VALUE*)alloca(sizeof(D3D12_CLEAR_VALUE) ); + clearValue = (D3D12_CLEAR_VALUE*)BX_STACK_ALLOC(sizeof(D3D12_CLEAR_VALUE) ); clearValue->Format = tfi.m_fmtDsv; clearValue->DepthStencil.Depth = 1.0f; clearValue->DepthStencil.Stencil = 0; @@ -5235,7 +5235,7 @@ namespace bgfx { namespace d3d12 state |= D3D12_RESOURCE_STATE_RENDER_TARGET; state &= ~D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; - clearValue = (D3D12_CLEAR_VALUE*)alloca(sizeof(D3D12_CLEAR_VALUE) ); + clearValue = (D3D12_CLEAR_VALUE*)BX_STACK_ALLOC(sizeof(D3D12_CLEAR_VALUE) ); clearValue->Format = resourceDesc.Format; clearValue->Color[0] = 0.0f; clearValue->Color[1] = 0.0f; diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index eb4d051b157..22c5069b759 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -1634,7 +1634,7 @@ namespace bgfx { namespace gl } else { - data = bx::alignPtr(alloca(size+16), 0, 16); + data = bx::alignPtr(BX_STACK_ALLOC(size+16), 0, 16); } flushGlError(); @@ -2338,7 +2338,7 @@ namespace bgfx { namespace gl if (0 < numCmpFormats) { numCmpFormats = numCmpFormats > 256 ? 256 : numCmpFormats; - cmpFormat = (GLint*)alloca(sizeof(GLint)*numCmpFormats); + cmpFormat = (GLint*)BX_STACK_ALLOC(sizeof(GLint)*numCmpFormats); GL_CHECK(glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, cmpFormat) ); for (GLint ii = 0; ii < numCmpFormats; ++ii) @@ -5137,7 +5137,7 @@ namespace bgfx { namespace gl } uint32_t maxLength = bx::uint32_max(max0, max1); - char* name = (char*)alloca(maxLength + 1); + char* name = (char*)BX_STACK_ALLOC(maxLength + 1); BX_TRACE("Program %d", m_id); BX_TRACE("Attributes (%d):", activeAttribs); @@ -6310,7 +6310,7 @@ namespace bgfx { namespace gl && 0 != bx::strCmp(code, "#version", 8) ) // #2000 { int32_t tempLen = code.getLength() + (4<<10); - char* temp = (char*)alloca(tempLen); + char* temp = (char*)BX_STACK_ALLOC(tempLen); bx::StaticMemoryBlockWriter writer(temp, tempLen); if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES) @@ -6846,7 +6846,7 @@ namespace bgfx { namespace gl { int32_t codeLen = (int32_t)bx::strLen(code); int32_t tempLen = codeLen + (4<<10); - char* temp = (char*)alloca(tempLen); + char* temp = (char*)BX_STACK_ALLOC(tempLen); bx::StaticMemoryBlockWriter writer(temp, tempLen); int32_t verLen = 0; @@ -6918,7 +6918,7 @@ namespace bgfx { namespace gl GLsizei len; GL_CHECK(glGetShaderiv(m_id, GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE, &len) ); - char* source = (char*)alloca(len); + char* source = (char*)BX_STACK_ALLOC(len); GL_CHECK(glGetTranslatedShaderSourceANGLE(m_id, len, &len, source) ); BX_TRACE("ANGLE source (len: %d):\n%s\n####", len, source); diff --git a/tools/shaderc/shaderc.cpp b/tools/shaderc/shaderc.cpp index e374f666775..f523c193096 100644 --- a/tools/shaderc/shaderc.cpp +++ b/tools/shaderc/shaderc.cpp @@ -497,7 +497,7 @@ namespace bgfx int32_t len = bx::vsnprintf(out, max, _format, argList); if (len > max) { - out = (char*)alloca(len); + out = (char*)BX_STACK_ALLOC(len); len = bx::vsnprintf(out, len, _format, argList); } @@ -592,7 +592,7 @@ namespace bgfx int32_t len = bx::vsnprintf(out, max, _format, argList); if (len > max) { - out = (char*)alloca(len); + out = (char*)BX_STACK_ALLOC(len); len = bx::vsnprintf(out, len, _format, argList); } @@ -683,7 +683,7 @@ namespace bgfx { const int32_t len = bx::strLen(_find); - char* replace = (char*)alloca(len+1); + char* replace = (char*)BX_STACK_ALLOC(len+1); bx::strCopy(replace, len+1, _replace); for (int32_t ii = bx::strLen(replace); ii < len; ++ii) { @@ -2747,7 +2747,7 @@ namespace bgfx bin2c = baseName(outFilePath); if (!bin2c.isEmpty() ) { - char* temp = (char*)alloca(bin2c.getLength()+1); + char* temp = (char*)BX_STACK_ALLOC(bin2c.getLength()+1); for (uint32_t ii = 0, num = bin2c.getLength(); ii < num; ++ii) { char ch = bin2c.getPtr()[ii];