mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2024-10-14 16:32:17 +00:00
Switch from using strncpy to strncpy_s. (#1809)
This commit is contained in:
parent
38e3e8f800
commit
4c130b9051
@ -1701,7 +1701,7 @@ bool VulkanHppGenerator::containsFloatingPoints( std::vector<MemberData> const &
|
|||||||
{
|
{
|
||||||
for ( auto const & m : members )
|
for ( auto const & m : members )
|
||||||
{
|
{
|
||||||
if (m.type.isValue())
|
if ( m.type.isValue() )
|
||||||
{
|
{
|
||||||
if ( ( m.type.type == "float" ) || ( m.type.type == "double" ) )
|
if ( ( m.type.type == "float" ) || ( m.type.type == "double" ) )
|
||||||
{
|
{
|
||||||
@ -1710,7 +1710,7 @@ bool VulkanHppGenerator::containsFloatingPoints( std::vector<MemberData> const &
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto structureIt = m_structs.find( m.type.type );
|
auto structureIt = m_structs.find( m.type.type );
|
||||||
if (structureIt != m_structs.end() && containsFloatingPoints(structureIt->second.members))
|
if ( structureIt != m_structs.end() && containsFloatingPoints( structureIt->second.members ) )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -9970,7 +9970,7 @@ std::string VulkanHppGenerator::generateReturnStatement( std::string const & com
|
|||||||
std::string returnStatement;
|
std::string returnStatement;
|
||||||
if ( commandData.returnType.starts_with( "Vk" ) )
|
if ( commandData.returnType.starts_with( "Vk" ) )
|
||||||
{
|
{
|
||||||
if ( ( commandData.successCodes.size() == 1 ) || enumerating || ( commandName == "vkGetDeviceFaultInfoEXT") )
|
if ( ( commandData.successCodes.size() == 1 ) || enumerating || ( commandName == "vkGetDeviceFaultInfoEXT" ) )
|
||||||
{
|
{
|
||||||
assert( commandData.successCodes[0] == "VK_SUCCESS" );
|
assert( commandData.successCodes[0] == "VK_SUCCESS" );
|
||||||
if ( raii || commandData.errorCodes.empty() )
|
if ( raii || commandData.errorCodes.empty() )
|
||||||
@ -10722,16 +10722,13 @@ std::string VulkanHppGenerator::generateStructConstructorsEnhanced( std::pair<st
|
|||||||
assert( mit->arraySizes.size() == 1 );
|
assert( mit->arraySizes.size() == 1 );
|
||||||
static const std::string copyOpsTemplate = R"(
|
static const std::string copyOpsTemplate = R"(
|
||||||
VULKAN_HPP_ASSERT( ${memberName}_.size() < ${arraySize} );
|
VULKAN_HPP_ASSERT( ${memberName}_.size() < ${arraySize} );
|
||||||
${copyOp}( ${memberName}, ${memberName}_.data(), ${arraySizeExpression} );)";
|
${copyOp}( ${memberName}, ${memberSize}, ${memberName}_.data(), ${memberName}_.size() );)";
|
||||||
|
|
||||||
std::string arraySizeExpression = ( mit->lenExpressions[0] == "null-terminated" )
|
|
||||||
? ( "std::min<size_t>( " + mit->name + "_.size(), " + mit->arraySizes[0] + " )" )
|
|
||||||
: ( mit->lenExpressions[0] + " * sizeof( " + argumentType + " )" );
|
|
||||||
copyOps += replaceWithMap( copyOpsTemplate,
|
copyOps += replaceWithMap( copyOpsTemplate,
|
||||||
{ { "arraySize", mit->arraySizes[0] },
|
{ { "arraySize", mit->arraySizes[0] },
|
||||||
{ "arraySizeExpression", arraySizeExpression },
|
{ "copyOp", mit->lenExpressions[0] == "null-terminated" ? "strncpy_s" : "memcpy_s" },
|
||||||
{ "copyOp", mit->lenExpressions[0] == "null-terminated" ? "strncpy" : "memcpy" },
|
{ "memberName", mit->name },
|
||||||
{ "memberName", mit->name } } );
|
{ "memberSize", mit->arraySizes[0] } } );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -11450,7 +11447,7 @@ std::string VulkanHppGenerator::generateStructSetter( std::string const & struct
|
|||||||
${structureName} & set${ArrayName}( std::string const & ${arrayName}_ ) VULKAN_HPP_NOEXCEPT
|
${structureName} & set${ArrayName}( std::string const & ${arrayName}_ ) VULKAN_HPP_NOEXCEPT
|
||||||
{
|
{
|
||||||
VULKAN_HPP_ASSERT( ${arrayName}_.size() < ${arraySize} );
|
VULKAN_HPP_ASSERT( ${arrayName}_.size() < ${arraySize} );
|
||||||
strncpy( ${arrayName}, ${arrayName}_.data(), std::min<size_t>( ${arrayName}_.size(), ${arraySize} ) );
|
strncpy_s( ${arrayName}, ${arraySize}, ${arrayName}_.data(), ${arrayName}_.size() );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
|
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
|
||||||
|
Loading…
Reference in New Issue
Block a user