mirror of
https://github.com/wolfpld/tracy.git
synced 2026-09-22 02:04:23 +00:00
Use strzcpy in client library.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "TracyFastVector.hpp"
|
||||
#include "TracyStringHelpers.hpp"
|
||||
#include "../common/TracyAlloc.hpp"
|
||||
#include "../common/TracyString.hpp"
|
||||
#include "../common/TracySystem.hpp"
|
||||
|
||||
|
||||
@@ -1461,8 +1462,7 @@ static const char* DecodeCallstackPtrFastExternal( uint64_t ptr )
|
||||
}
|
||||
if( symname )
|
||||
{
|
||||
strncpy( ret, symname, sizeof( ret ) - 1 );
|
||||
ret[sizeof( ret ) - 1] = '\0';
|
||||
strzcpy( ret, symname, sizeof( ret ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <stdio.h>
|
||||
#include <thread>
|
||||
|
||||
#include "../../common/TracyString.hpp"
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
namespace etw
|
||||
@@ -330,9 +332,7 @@ static Session StartSingletonKernelLoggerSession( ULONGLONG EnableFlags )
|
||||
{
|
||||
Session session = {};
|
||||
|
||||
size_t maxlen = sizeof( session.name ) - 1;
|
||||
strncpy( session.name, KERNEL_LOGGER_NAMEA, maxlen );
|
||||
session.name[maxlen] = '\0';
|
||||
strzcpy( session.name, KERNEL_LOGGER_NAMEA, sizeof( session.name ) );
|
||||
|
||||
auto& props = session.properties;
|
||||
props.LoggerNameOffset = offsetof( Session, name );
|
||||
@@ -364,9 +364,7 @@ static Session StartPrivateKernelSession( const CHAR* name )
|
||||
{
|
||||
Session session = {};
|
||||
|
||||
size_t maxlen = sizeof( session.name ) - 1;
|
||||
strncpy( session.name, name, maxlen );
|
||||
session.name[maxlen] = '\0';
|
||||
strzcpy( session.name, name, sizeof( session.name ) );
|
||||
|
||||
auto& props = session.properties;
|
||||
props.LoggerNameOffset = offsetof( Session, name );
|
||||
@@ -398,9 +396,7 @@ static Session StartUserSession( const CHAR* name )
|
||||
{
|
||||
Session session = {};
|
||||
|
||||
size_t maxlen = sizeof( session.name ) - 1;
|
||||
strncpy( session.name, name, maxlen );
|
||||
session.name[maxlen] = '\0';
|
||||
strzcpy( session.name, name, sizeof( session.name ) );
|
||||
|
||||
auto& props = session.properties;
|
||||
props.LoggerNameOffset = offsetof( Session, name );
|
||||
|
||||
@@ -26,6 +26,7 @@ using CUDACtx = std::nullptr_t;
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include <string_view>
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
@@ -405,7 +406,7 @@ struct StringTable {
|
||||
if (!table.fetch(str, memoized)) {
|
||||
ZoneNamedN(lookup, "StringTable::insert", instrument);
|
||||
char* copy = (char*)tracyMalloc(str.size() + 1);
|
||||
strncpy(copy, str.data(), str.size());
|
||||
memcpy(copy, str.data(), str.size());
|
||||
copy[str.size()] = '\0';
|
||||
std::string_view value (copy, str.size());
|
||||
auto [it, inserted] = table.emplace(value, value);
|
||||
|
||||
Reference in New Issue
Block a user