diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 7d0c47ad8..77f0af162 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -3499,7 +3499,7 @@ namespace bgfx cmdbuf.write(handle); cmdbuf.write(uniform.m_type); cmdbuf.write(uniform.m_num); - uint8_t len = (uint8_t)strlen(_name)+1; + uint8_t len = (uint8_t)bx::strnlen(_name)+1; cmdbuf.write(len); cmdbuf.write(_name, len); } @@ -3527,7 +3527,7 @@ namespace bgfx cmdbuf.write(handle); cmdbuf.write(_type); cmdbuf.write(_num); - uint8_t len = (uint8_t)strlen(_name)+1; + uint8_t len = (uint8_t)bx::strnlen(_name)+1; cmdbuf.write(len); cmdbuf.write(_name, len); } @@ -3603,7 +3603,7 @@ namespace bgfx BGFX_API_FUNC(void saveScreenShot(const char* _filePath) ) { CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::SaveScreenShot); - uint16_t len = (uint16_t)strlen(_filePath)+1; + uint16_t len = (uint16_t)bx::strnlen(_filePath)+1; cmdbuf.write(len); cmdbuf.write(_filePath, len); } @@ -3622,7 +3622,7 @@ namespace bgfx { CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::UpdateViewName); cmdbuf.write(_id); - uint16_t len = (uint16_t)strlen(_name)+1; + uint16_t len = (uint16_t)bx::strnlen(_name)+1; cmdbuf.write(len); cmdbuf.write(_name, len); } diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index e55606b85..467edeac3 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -980,7 +980,7 @@ namespace bgfx { namespace gl // // If is 0 then is assumed to be null-terminated. - uint32_t size = (0 == _length ? (uint32_t)strlen(_marker) : _length) + 1; + uint32_t size = (0 == _length ? (uint32_t)bx::strnlen(_marker) : _length) + 1; size *= sizeof(wchar_t); wchar_t* name = (wchar_t*)alloca(size); mbstowcs(name, _marker, size-2); @@ -1039,7 +1039,7 @@ namespace bgfx { namespace gl glGetError(); // ignore error if glGetString returns NULL. if (NULL != str) { - return bx::hashMurmur2A(str, (uint32_t)strlen(str) ); + return bx::hashMurmur2A(str, (uint32_t)bx::strnlen(str) ); } return 0; @@ -1051,7 +1051,7 @@ namespace bgfx { namespace gl { char name[1024]; const char* pos = _extensions; - const char* end = _extensions + strlen(_extensions); + const char* end = _extensions + bx::strnlen(_extensions); while (pos < end) { uint32_t len; @@ -1062,7 +1062,7 @@ namespace bgfx { namespace gl } else { - len = bx::uint32_min(sizeof(name), (uint32_t)strlen(pos) ); + len = bx::uint32_min(sizeof(name), (uint32_t)bx::strnlen(pos) ); } strncpy(name, pos, len); @@ -1469,7 +1469,7 @@ namespace bgfx { namespace gl for (uint32_t ii = 0; ii < BX_COUNTOF(s_vendorIds); ++ii) { const VendorId& vendorId = s_vendorIds[ii]; - if (0 == strncmp(vendorId.name, m_vendor, strlen(vendorId.name) ) ) + if (0 == strncmp(vendorId.name, m_vendor, bx::strnlen(vendorId.name) ) ) { g_caps.vendorId = vendorId.id; break; @@ -1559,7 +1559,7 @@ namespace bgfx { namespace gl { char name[1024]; const char* pos = extensions; - const char* end = extensions + strlen(extensions); + const char* end = extensions + bx::strnlen(extensions); uint32_t index = 0; while (pos < end) { @@ -1571,7 +1571,7 @@ namespace bgfx { namespace gl } else { - len = bx::uint32_min(sizeof(name), (uint32_t)strlen(pos) ); + len = bx::uint32_min(sizeof(name), (uint32_t)bx::strnlen(pos) ); } strncpy(name, pos, len); @@ -5294,7 +5294,7 @@ namespace bgfx { namespace gl void writeString(bx::WriterI* _writer, const char* _str) { - bx::write(_writer, _str, (int32_t)strlen(_str) ); + bx::write(_writer, _str, (int32_t)bx::strnlen(_str) ); } void writeStringf(bx::WriterI* _writer, const char* _format, ...) @@ -5311,8 +5311,8 @@ namespace bgfx { namespace gl void strins(char* _str, const char* _insert) { - size_t len = strlen(_insert); - memmove(&_str[len], _str, strlen(_str)+1); + size_t len = bx::strnlen(_insert); + memmove(&_str[len], _str, bx::strnlen(_str)+1); memcpy(_str, _insert, len); } @@ -5382,7 +5382,7 @@ namespace bgfx { namespace gl { if (GL_COMPUTE_SHADER != m_type) { - int32_t codeLen = (int32_t)strlen(code); + int32_t codeLen = (int32_t)bx::strnlen(code); int32_t tempLen = codeLen + (4<<10); char* temp = (char*)alloca(tempLen); bx::StaticMemoryBlockWriter writer(temp, tempLen); diff --git a/src/renderer_mtl.mm b/src/renderer_mtl.mm index 5d340a1ee..fccb15d45 100644 --- a/src/renderer_mtl.mm +++ b/src/renderer_mtl.mm @@ -1812,7 +1812,7 @@ namespace bgfx { namespace mtl void writeString(bx::WriterI* _writer, const char* _str) { - bx::write(_writer, _str, (int32_t)strlen(_str) ); + bx::write(_writer, _str, (int32_t)bx::strnlen(_str) ); } void ShaderMtl::create(const Memory* _mem) diff --git a/src/shader.cpp b/src/shader.cpp index 3d429726b..764932235 100644 --- a/src/shader.cpp +++ b/src/shader.cpp @@ -15,7 +15,7 @@ namespace bgfx bx::WriterI* writer = reinterpret_cast(_userData); char temp[512]; toString(temp, sizeof(temp), _instruction); - bx::write(writer, temp, (int32_t)strlen(temp) ); + bx::write(writer, temp, (int32_t)bx::strnlen(temp) ); return true; } @@ -24,7 +24,7 @@ namespace bgfx bx::WriterI* writer = reinterpret_cast(_userData); char temp[512]; toString(temp, sizeof(temp), _instruction); - bx::write(writer, temp, (int32_t)strlen(temp) ); + bx::write(writer, temp, (int32_t)bx::strnlen(temp) ); return true; } @@ -33,7 +33,7 @@ namespace bgfx bx::WriterI* writer = reinterpret_cast(_userData); char temp[512]; toString(temp, sizeof(temp), _instruction); - bx::write(writer, temp, (int32_t)strlen(temp) ); + bx::write(writer, temp, (int32_t)bx::strnlen(temp) ); return true; }