diff options
| author | Julian Andres Klode <julian.klode@canonical.com> | 2024-11-11 14:09:41 +0100 |
|---|---|---|
| committer | Julian Andres Klode <julian.klode@canonical.com> | 2024-11-20 15:04:28 +0100 |
| commit | 709adda89a575e6c542310e6632c090632bb9732 (patch) | |
| tree | cd53499ae57556e016f3d87dc3e596ec69919fd9 /ftparchive | |
| parent | b888c66c7244de9b20d174555ffdc22829d6c222 (diff) | |
ftparchive: cachedb: Remove 600-byte key limit
Instead of snprintf() into a fixed-size buffer, construct an
std::string using assign() and append().
A previous version used strprintf() which would have been
hilariously inefficient.
LP: #2087848
Diffstat (limited to 'ftparchive')
| -rw-r--r-- | ftparchive/cachedb.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ftparchive/cachedb.h b/ftparchive/cachedb.h index 98817b9ec..0002c6059 100644 --- a/ftparchive/cachedb.h +++ b/ftparchive/cachedb.h @@ -34,7 +34,7 @@ class CacheDB // Database state/access DBT Key; DBT Data; - char TmpKey[600]; + std::string TmpKey; DB *Dbp; bool DBLoaded; bool ReadOnly; @@ -45,8 +45,9 @@ class CacheDB { memset(&Key,0,sizeof(Key)); memset(&Data,0,sizeof(Data)); - Key.data = TmpKey; - Key.size = snprintf(TmpKey,sizeof(TmpKey),"%s:%s",FileName.c_str(), Type); + TmpKey.assign(FileName).append(":").append(Type); + Key.data = TmpKey.data(); + Key.size = TmpKey.size(); } void InitQueryStats() { |
