Replace ao::uvector<> with std::vector<> with a custom allocator.

Reference: https://hackingcpp.com/cpp/recipe/uninitialized_numeric_array.html

Tested by resizing the vector, setting a value, shrinking it, then
resizing it again. With both ao::uvector<> and std::vector<> with
the custom allocator, that set value remains. With std::vector<>'s
regular allocator, that value is reset to 0.
This commit is contained in:
David Korth 2023-09-16 23:50:43 -04:00
parent 4512f93957
commit d2a752a456
36 changed files with 160 additions and 1441 deletions

View File

@ -83,7 +83,7 @@ static uint32_t getStringTableOffset(const char *str)
}
// Not found. Add the string
// TODO: Check generated assembly; maybe memcmp() with ao::uvector<> is faster?
// TODO: Check generated assembly; maybe memcmp() with rp::uvector<> is faster?
const uint32_t offset = static_cast<uint32_t>(stringTable.size());
string entry(str);
stringTable.insert(stringTable.end(), entry.c_str(), entry.c_str() + entry.size() + 1);

View File

@ -24,8 +24,7 @@ using namespace LibRpTexture;
using std::string;
using std::vector;
// Uninitialized vector class.
// Reference: http://andreoffringa.org/?q=uvector
// Uninitialized vector class
#include "uvector.h"
namespace LibRomData {
@ -67,7 +66,7 @@ class GameCubeBNRPrivate final : public RomDataPrivate
// Banner comments
// - If BNR1: 1 item.
// - If BNR2: 6 items.
ao::uvector<gcn_banner_comment_t> comments;
rp::uvector<gcn_banner_comment_t> comments;
public:
/**

View File

@ -31,8 +31,7 @@
# include "librpbase/disc/CBCReader.hpp"
#endif /* ENABLE_DECRYPTION */
// Uninitialized vector class.
// Reference: http://andreoffringa.org/?q=uvector
// Uninitialized vector class
#include "uvector.h"
namespace LibRpBase {
@ -88,7 +87,7 @@ class WiiWADPrivate final : public LibRpBase::RomDataPrivate
std::string wadName;
// TMD contents table.
ao::uvector<RVL_Content_Entry> tmdContentsTbl;
rp::uvector<RVL_Content_Entry> tmdContentsTbl;
const RVL_Content_Entry *pIMETContent;
uint32_t imetContentOffset; // relative to start of data area

View File

@ -109,7 +109,7 @@ class Xbox360_STFS_Private final : public RomDataPrivate
Xbox360_XEX *xex;
// File table.
ao::uvector<STFS_DirEntry_t> fileTable;
rp::uvector<STFS_DirEntry_t> fileTable;
/**
* Convert a block number to an offset.

View File

@ -76,7 +76,7 @@ class Xbox360_XDBF_Private final : public RomDataPrivate
// Entry table.
// NOTE: Data is *not* byteswapped on load.
ao::uvector<XDBF_Entry> entryTable;
rp::uvector<XDBF_Entry> entryTable;
// Data start offset within the file.
uint32_t data_offset;
@ -94,8 +94,8 @@ class Xbox360_XDBF_Private final : public RomDataPrivate
array<int16_t, XDBF_LANGUAGE_MAX> strTblIndexes;
// String tables.
// NOTE: These are *pointers* to ao::uvector<>.
array<ao::uvector<char>*, XDBF_LANGUAGE_MAX> strTbls;
// NOTE: These are *pointers* to rp::uvector<>.
array<rp::uvector<char>*, XDBF_LANGUAGE_MAX> strTbls;
// If true, this XDBF section is in an XEX executable.
// Some fields shouldn't be displayed.
@ -122,7 +122,7 @@ class Xbox360_XDBF_Private final : public RomDataPrivate
* @param langID Language ID.
* @return Pointer to string table on success; nullptr on error.
*/
const ao::uvector<char> *loadStringTable_SPA(XDBF_Language_e langID);
const rp::uvector<char> *loadStringTable_SPA(XDBF_Language_e langID);
public:
/**
@ -306,7 +306,7 @@ Xbox360_XDBF_Private::Xbox360_XDBF_Private(const IRpFilePtr &file, bool xex)
Xbox360_XDBF_Private::~Xbox360_XDBF_Private()
{
// Delete any allocated string tables.
for (ao::uvector<char> *pStrTbl : strTbls) {
for (rp::uvector<char> *pStrTbl : strTbls) {
delete pStrTbl;
}
}
@ -393,7 +393,7 @@ int Xbox360_XDBF_Private::initStrTblIndexes(void)
* @param langID Language ID.
* @return Pointer to string table on success; nullptr on error.
*/
const ao::uvector<char> *Xbox360_XDBF_Private::loadStringTable_SPA(XDBF_Language_e langID)
const rp::uvector<char> *Xbox360_XDBF_Private::loadStringTable_SPA(XDBF_Language_e langID)
{
assert(langID >= 0);
assert(langID < XDBF_LANGUAGE_MAX);
@ -434,7 +434,7 @@ const ao::uvector<char> *Xbox360_XDBF_Private::loadStringTable_SPA(XDBF_Language
// Size is out of range.
return nullptr;
}
ao::uvector<char> *vec = new ao::uvector<char>(str_tbl_sz);
rp::uvector<char> *vec = new rp::uvector<char>(str_tbl_sz);
const unsigned int str_tbl_addr = be32_to_cpu(entry->offset) + this->data_offset;
size_t size = file->seekAndRead(str_tbl_addr, vec->data(), str_tbl_sz);
@ -477,7 +477,7 @@ string Xbox360_XDBF_Private::loadString_SPA(XDBF_Language_e langID, uint16_t str
return ret;
// Get the string table.
const ao::uvector<char> *vec = strTbls[langID];
const rp::uvector<char> *vec = strTbls[langID];
if (!vec) {
vec = loadStringTable_SPA(langID);
if (!vec) {

View File

@ -88,7 +88,7 @@ class Xbox360_XEX_Private final : public RomDataPrivate
// Optional header table.
// NOTE: This array of structs **IS NOT** byteswapped!
ao::uvector<XEX2_Optional_Header_Tbl> optHdrTbl;
rp::uvector<XEX2_Optional_Header_Tbl> optHdrTbl;
// Execution ID. (XEX2_OPTHDR_EXECUTION_ID)
// Initialized by getXdbfResInfo().
@ -124,7 +124,7 @@ class Xbox360_XEX_Private final : public RomDataPrivate
uint32_t physaddr; // Physical address in the PE executable
uint32_t length; // Length of segment
};
ao::uvector<BasicZDataSeg_t> basicZDataSegments;
rp::uvector<BasicZDataSeg_t> basicZDataSegments;
// Amount of data we'll read for the PE header.
// NOTE: Changed from `static const unsigned int` to #define
@ -133,9 +133,9 @@ class Xbox360_XEX_Private final : public RomDataPrivate
#ifdef ENABLE_LIBMSPACK
// Decompressed EXE header.
ao::uvector<uint8_t> lzx_peHeader;
rp::uvector<uint8_t> lzx_peHeader;
// Decompressed XDBF section.
ao::uvector<uint8_t> lzx_xdbfSection;
rp::uvector<uint8_t> lzx_xdbfSection;
#endif /* ENABLE_LIBMSPACK */
/**
@ -166,10 +166,10 @@ class Xbox360_XEX_Private final : public RomDataPrivate
* at the beginning of the data (low byte == 0xFF).
*
* @param header_id [in] Optional header ID.
* @param pVec [out] ao::uvector<uint8_t>&
* @param pVec [out] rp::uvector<uint8_t>&
* @return Number of bytes read on success; 0 on error.
*/
size_t getOptHdrData(uint32_t header_id, ao::uvector<uint8_t> &pVec);
size_t getOptHdrData(uint32_t header_id, rp::uvector<uint8_t> &pVec);
/**
* Get the resource information.
@ -400,10 +400,10 @@ size_t Xbox360_XEX_Private::getOptHdrData(uint32_t header_id, uint32_t *pOut32)
* at the beginning of the data (low byte == 0xFF).
*
* @param header_id [in] Optional header ID.
* @param pVec [out] ao::uvector<uint8_t>&
* @param pVec [out] rp::uvector<uint8_t>&
* @return Number of bytes read on success; 0 on error.
*/
size_t Xbox360_XEX_Private::getOptHdrData(uint32_t header_id, ao::uvector<uint8_t> &pVec)
size_t Xbox360_XEX_Private::getOptHdrData(uint32_t header_id, rp::uvector<uint8_t> &pVec)
{
assert((header_id & 0xFF) > 0x01);
if ((header_id & 0xFF) <= 0x01) {
@ -463,7 +463,7 @@ const XEX2_Resource_Info *Xbox360_XEX_Private::getXdbfResInfo(const char *resour
}
// General data buffer for loading optional headers.
ao::uvector<uint8_t> u8_data;
rp::uvector<uint8_t> u8_data;
// Title ID is part of the execution ID, so load it if it
// hasn't been loaded already.
@ -578,7 +578,7 @@ int Xbox360_XEX_Private::initPeReader(void)
}
// Get the file format info.
ao::uvector<uint8_t> u8_ffi;
rp::uvector<uint8_t> u8_ffi;
size_t size = getOptHdrData(XEX2_OPTHDR_FILE_FORMAT_INFO, u8_ffi);
if (size < sizeof(fileFormatInfo)) {
// Seek and/or read error.
@ -1134,7 +1134,7 @@ Xbox360_Version_t Xbox360_XEX_Private::getMinKernelVersion(void)
// Minimum kernel version is determined by checking the
// import libraries and taking the maximum version.
ao::uvector<uint8_t> u8_implib;
rp::uvector<uint8_t> u8_implib;
size_t size = getOptHdrData(XEX2_OPTHDR_IMPORT_LIBRARIES, u8_implib);
if (size < sizeof(XEX2_Import_Libraries_Header) + (sizeof(XEX2_Import_Library_Entry) * 2)) {
// Too small...
@ -1639,7 +1639,7 @@ int Xbox360_XEX::loadFieldData(void)
}
// Original executable name
ao::uvector<uint8_t> u8_data;
rp::uvector<uint8_t> u8_data;
size_t size = d->getOptHdrData(XEX2_OPTHDR_ORIGINAL_PE_NAME, u8_data);
if (size > sizeof(uint32_t)) {
// Sanity check: Must be less than 260 bytes. (PATH_MAX)

View File

@ -27,8 +27,7 @@ namespace LibRpFile {
class IRpFile;
}
// Uninitialized vector class.
// Reference: http://andreoffringa.org/?q=uvector
// Uninitialized vector class
#include "uvector.h"
namespace LibRomData {
@ -131,7 +130,7 @@ class Nintendo3DSPrivate final : public LibRpBase::RomDataPrivate
// Content chunk records. (CIA only)
// Loaded by loadTicketAndTMD().
ao::uvector<N3DS_Content_Chunk_Record_t> content_chunks;
rp::uvector<N3DS_Content_Chunk_Record_t> content_chunks;
// TODO: Move the pointers to the union?
// That requires careful memory management...

View File

@ -32,9 +32,9 @@ using namespace LibRpText;
using std::string;
using std::vector;
// Uninitialized vector class.
// Reference: http://andreoffringa.org/?q=uvector
// Uninitialized vector class
#include "uvector.h"
#include "span.hh"
using vhvc::span;
using vhvc::reinterpret_span;
@ -138,7 +138,7 @@ class ELFPrivate final : public RomDataPrivate
// Section Header information
string osVersion; // Operating system version.
ao::uvector<uint8_t> build_id; // GNU `ld` build ID. (raw data)
rp::uvector<uint8_t> build_id; // GNU `ld` build ID. (raw data)
const char *build_id_type; // Build ID type.
/**
@ -195,7 +195,7 @@ class ELFPrivate final : public RomDataPrivate
* @param out The output vector. Its size determines how much data is read.
* @return 0 on success; non-zero on error.
*/
int readDataAtVA(uint64_t vaddr, ao::uvector<uint8_t> &out);
int readDataAtVA(uint64_t vaddr, rp::uvector<uint8_t> &out);
/**
* Add PT_DYNAMIC fields.
@ -744,7 +744,7 @@ int ELFPrivate::checkSectionHeaders(void)
* @param out The output vector. Its size determines how much data is read.
* @return 0 on success; non-zero on error.
*/
int ELFPrivate::readDataAtVA(uint64_t vaddr, ao::uvector<uint8_t> &out)
int ELFPrivate::readDataAtVA(uint64_t vaddr, rp::uvector<uint8_t> &out)
{
// Find the segment
const uint64_t vend = vaddr + out.size();
@ -793,7 +793,7 @@ int ELFPrivate::addPtDynamicFields(void)
}
// Read the header.
ao::uvector<uint8_t> pt_dyn_buf;
rp::uvector<uint8_t> pt_dyn_buf;
pt_dyn_buf.resize(static_cast<unsigned int>(pt_dynamic.p_filesz));
size_t size = file->seekAndRead(pt_dynamic.p_offset, pt_dyn_buf.data(), pt_dyn_buf.size());
if (size != pt_dyn_buf.size()) {
@ -846,7 +846,7 @@ int ELFPrivate::addPtDynamicFields(void)
break;
}
ao::uvector<uint8_t> strtab_buf;
rp::uvector<uint8_t> strtab_buf;
span<const char> strtab;
assert(val_dtag[DT_STRSZ] < 1*1024*1024);
if (has_dtag[DT_STRTAB] && has_dtag[DT_STRSZ] && val_dtag[DT_STRSZ] < 1*1024*1024) {
@ -1003,7 +1003,7 @@ int ELFPrivate::addSymbolFields(span<const char> dynsym_strtab)
*/
auto parse_symtab = [this](vector<Elf64_Sym> &out, const symtab_info_t &info) -> void {
ao::uvector<uint8_t> buf;
rp::uvector<uint8_t> buf;
if (info.size == 0 || info.size > 1*1024*1024)
return;
if (info.entsize < (Elf_Header.primary.e_class == ELFCLASS64 ? sizeof(Elf64_Sym) : sizeof(Elf32_Sym)))
@ -1108,7 +1108,7 @@ int ELFPrivate::addSymbolFields(span<const char> dynsym_strtab)
fields.addField_listData(name, &params);
};
auto read_strtab = [this](ao::uvector<uint8_t> &buf, const symtab_info_t &info) -> span<const char> {
auto read_strtab = [this](rp::uvector<uint8_t> &buf, const symtab_info_t &info) -> span<const char> {
if (info.strtab_size == 0 || info.strtab_size > 1*1024*1024)
return span<const char>();
buf.resize(static_cast<size_t>(info.strtab_size));
@ -1125,7 +1125,7 @@ int ELFPrivate::addSymbolFields(span<const char> dynsym_strtab)
return span<const char>();
};
ao::uvector<uint8_t> symtab_buf, dynsym_buf;
rp::uvector<uint8_t> symtab_buf, dynsym_buf;
add_symbol_tab("SHT_SYMTAB", sht_symtab, read_strtab(symtab_buf, sht_symtab));
if (dynsym_strtab.size() == 0) {
dynsym_strtab = read_strtab(dynsym_buf, sht_dynsym);

View File

@ -20,6 +20,7 @@ using namespace LibRpText;
// C++ STL classes
using std::string;
using std::vector;
using vhvc::span;
using vhvc::reinterpret_span;
using vhvc::reinterpret_span_limit;
@ -798,7 +799,7 @@ int EXEPrivate::addFields_NE_Import(void)
return -EIO; // Short read
rel_count = le16_to_cpu(rel_count);
ao::uvector<uint8_t> rel_buf;
rp::uvector<uint8_t> rel_buf;
rel_buf.resize(rel_count*sizeof(NE_Reloc));
nread = file->seekAndRead(seg_offset + seg_size + 2, rel_buf.data(), rel_buf.size());
if (nread != rel_buf.size())

View File

@ -203,7 +203,7 @@ int EXEPrivate::loadPEResourceTypes(void)
* @return 0 on success; negative POSIX error code on error.
*/
int EXEPrivate::readPEImpExpDir(IMAGE_DATA_DIRECTORY &dataDir, int type,
size_t minSize, size_t maxSize, ao::uvector<uint8_t> &dirTbl)
size_t minSize, size_t maxSize, rp::uvector<uint8_t> &dirTbl)
{
if (!file || !file->isOpen()) {
// File isn't open.
@ -329,7 +329,7 @@ int EXEPrivate::readPEImportDir(void)
// IMAGE_IMPORT_DIRECTORY in the former case.
IMAGE_DATA_DIRECTORY dataDir;
ao::uvector<uint8_t> impDirTbl;
rp::uvector<uint8_t> impDirTbl;
int res = readPEImpExpDir(dataDir, IMAGE_DATA_DIRECTORY_IMPORT_TABLE,
sizeof(IMAGE_IMPORT_DIRECTORY), 4*1024*1024, impDirTbl);
if (res)
@ -771,7 +771,7 @@ void EXEPrivate::addFields_PE(void)
int EXEPrivate::addFields_PE_Export(void)
{
IMAGE_DATA_DIRECTORY dataDir;
ao::uvector<uint8_t> expDirTbl;
rp::uvector<uint8_t> expDirTbl;
int res = readPEImpExpDir(dataDir, IMAGE_DATA_DIRECTORY_EXPORT_TABLE,
sizeof(IMAGE_EXPORT_DIRECTORY), 4*1024*1024, expDirTbl);

View File

@ -18,9 +18,9 @@
#include "disc/PEResourceReader.hpp"
// Uninitialized vector class.
// Reference: http://andreoffringa.org/?q=uvector
// Uninitialized vector class
#include "uvector.h"
#include "span.hh"
// TinyXML2
@ -123,7 +123,7 @@ class EXEPrivate final : public LibRpBase::RomDataPrivate
int loadNEResident(void);
// Resident portion of NE header (up to the end of entry table)
ao::uvector<uint8_t> ne_resident;
rp::uvector<uint8_t> ne_resident;
bool ne_resident_loaded = false;
vhvc::span<const NE_Segment> ne_segment_table;
vhvc::span<const uint8_t> ne_resource_table;
@ -139,7 +139,7 @@ class EXEPrivate final : public LibRpBase::RomDataPrivate
int loadNENonResidentNames(void);
// Contents of the non-resident name table (NE)
ao::uvector<char> ne_nonresident_name_table;
rp::uvector<char> ne_nonresident_name_table;
bool ne_nonresident_name_table_loaded = false;
/**
@ -188,7 +188,7 @@ class EXEPrivate final : public LibRpBase::RomDataPrivate
uint16_t pe_subsystem;
// PE section headers.
ao::uvector<IMAGE_SECTION_HEADER> pe_sections;
rp::uvector<IMAGE_SECTION_HEADER> pe_sections;
/**
* Load the PE section table.
@ -225,7 +225,7 @@ class EXEPrivate final : public LibRpBase::RomDataPrivate
* @return 0 on success; negative POSIX error code on error.
*/
int readPEImpExpDir(IMAGE_DATA_DIRECTORY &dataDir, int type,
size_t minSize, size_t maxSize, ao::uvector<uint8_t> &dirTbl);
size_t minSize, size_t maxSize, rp::uvector<uint8_t> &dirTbl);
/**
* Read a block of null-terminated strings, where the length of the

View File

@ -20,8 +20,7 @@ using namespace LibRpText;
using std::string;
using std::vector;
// Uninitialized vector class.
// Reference: http://andreoffringa.org/?q=uvector
// Uninitialized vector class
#include "uvector.h"
namespace LibRomData {
@ -84,7 +83,7 @@ class MachOPrivate final : public RomDataPrivate
// Mach-O formats and headers.
vector<Mach_Format> machFormats;
ao::uvector<mach_header> machHeaders;
rp::uvector<mach_header> machHeaders;
/**
* Check the Mach-O magic number.

View File

@ -37,8 +37,7 @@ using std::unique_ptr;
# define U82T_s(u8str) (u8str)
#endif /* _WIN32 */
// Uninitialized vector class.
// Reference: http://andreoffringa.org/?q=uvector
// Uninitialized vector class
#include "uvector.h"
namespace LibRomData {
@ -83,7 +82,7 @@ class AmiiboDataPrivate {
public:
// amiibo.bin data
ao::uvector<uint8_t> amiibo_bin_data;
rp::uvector<uint8_t> amiibo_bin_data;
// Convenience pointers to amiibo.bin structs.
const AmiiboBinHeader *pHeader;

View File

@ -91,18 +91,18 @@ class CisoPspReaderPrivate : public SparseDiscReaderPrivate {
// High bit interpretation depends on CISO version.
// - v0/v1: If set, block is not compressed.
// - v2: If set, block is compressed using LZ4; otherwise, deflate.
ao::uvector<uint32_t> indexEntries;
rp::uvector<uint32_t> indexEntries;
// Block cache.
ao::uvector<uint8_t> blockCache;
rp::uvector<uint8_t> blockCache;
uint32_t blockCacheIdx;
// Decompression buffer.
// (Same size as blockCache.)
ao::uvector<uint8_t> z_buffer;
rp::uvector<uint8_t> z_buffer;
// DAX: Size and NC area tables.
ao::uvector<uint16_t> daxSizeTable;
rp::uvector<uint16_t> daxSizeTable;
std::vector<uint8_t> daxNCTable; // 0 = compressed; 1 = not compressed
uint8_t index_shift; // Index shift value.
@ -432,7 +432,7 @@ CisoPspReader::CisoPspReader(const IRpFilePtr &file)
if (d->header.dax.nc_areas > 0) {
// Handle the NC (non-compressed) areas.
// This table is stored immediately after the index entry table.
ao::uvector<DaxNCArea> nc_areas;
rp::uvector<DaxNCArea> nc_areas;
nc_areas.resize(d->header.dax.nc_areas);
expected_size = d->header.dax.nc_areas * sizeof(DaxNCArea);
size = m_file->read(nc_areas.data(), expected_size);

View File

@ -50,15 +50,15 @@ class GczReaderPrivate : public SparseDiscReaderPrivate {
// Block pointers and hashes (NOTE: Byteswapped on demand)
// If bit 63 of the block pointer is set, it's not compressed.
// Hashes are Adler32.
ao::uvector<uint64_t> blockPointers;
ao::uvector<uint32_t> hashes;
rp::uvector<uint64_t> blockPointers;
rp::uvector<uint32_t> hashes;
// Decompression buffer
// (Same size as blockCache)
ao::uvector<uint8_t> z_buffer;
rp::uvector<uint8_t> z_buffer;
// Block cache
ao::uvector<uint8_t> blockCache;
rp::uvector<uint8_t> blockCache;
uint32_t blockCacheIdx;
// Starting offset of the data area

View File

@ -45,7 +45,7 @@ class IsoPartitionPrivate
// - Value: Directory entries.
// NOTE: Directory entries are variable-length, so this
// is a byte array, not an ISO_DirEntry array.
typedef ao::uvector<uint8_t> DirData_t;
typedef rp::uvector<uint8_t> DirData_t;
unordered_map<string, DirData_t> dir_data;
// ISO start offset. (in blocks)

View File

@ -50,7 +50,7 @@ class NASOSReaderPrivate : public SparseDiscReaderPrivate {
// Block map.
// Values are absolute block addresses, possibly with a shift amount.
// Special value: 0xFFFFFFFF == empty block
ao::uvector<uint32_t> blockMap;
rp::uvector<uint32_t> blockMap;
// Block address shift.
// - GCML: 0

View File

@ -45,7 +45,7 @@ class NEResourceReaderPrivate
uint32_t addr; // Address of the resource data. (0 = start of EXE)
uint32_t len; // Length of the resource data.
};
typedef ao::uvector<ResTblEntry> rsrc_dir_t;
typedef rp::uvector<ResTblEntry> rsrc_dir_t;
// Resource types.
unordered_map<uint16_t, rsrc_dir_t> res_types;

View File

@ -21,8 +21,7 @@ using std::string;
using std::unique_ptr;
using std::unordered_map;
// Uninitialized vector class.
// Reference: http://andreoffringa.org/?q=uvector
// Uninitialized vector class
#include "uvector.h"
namespace LibRomData {
@ -54,7 +53,7 @@ class PEResourceReaderPrivate
// IMAGE_RESOURCE_DATA_ENTRY, relative to rsrc_addr.
// NOTE: If the high bit is set, this is a subdirectory.
};
typedef ao::uvector<ResDirEntry> rsrc_dir_t;
typedef rp::uvector<ResDirEntry> rsrc_dir_t;
// Resource types. (Top-level directory.)
rsrc_dir_t res_types;

View File

@ -34,7 +34,7 @@ class WuxReaderPrivate : public SparseDiscReaderPrivate {
// Index table.
// Starts immediately after wuxHeader.
ao::uvector<uint32_t> idxTbl;
rp::uvector<uint32_t> idxTbl;
// Data start position.
// Starts immediately after the index table.

View File

@ -47,7 +47,7 @@ class XDVDFSPartitionPrivate
// - Value: Raw directory table from the disc.
// NOTE: Directory entries are variable-length, so this
// is a byte array, not an ISO_DirEntry array.
unordered_map<std::string, ao::uvector<uint8_t> > dirTables;
unordered_map<std::string, rp::uvector<uint8_t> > dirTables;
/**
* Get an entry within a specified directory table.
@ -55,15 +55,15 @@ class XDVDFSPartitionPrivate
* @param filename Filename to find, without subdirectories.
* @return Pointer to XDVDFS_DirEntry within dirTable, or nullptr if not found.
*/
const XDVDFS_DirEntry *getDirEntry(const ao::uvector<uint8_t> *dirTable, const char *filename);
const XDVDFS_DirEntry *getDirEntry(const rp::uvector<uint8_t> *dirTable, const char *filename);
/**
* Get the specified directory.
* This should *only* be the directory, not a filename.
* @param path Directory path.
* @return Pointer to directory table (ao::uvector), or nullptr if not found.
* @return Pointer to directory table (rp::uvector), or nullptr if not found.
*/
const ao::uvector<uint8_t> *getDirectory(const char *path);
const rp::uvector<uint8_t> *getDirectory(const char *path);
/**
* XDVDFS strcasecmp() implementation.
@ -164,7 +164,7 @@ int XDVDFSPartitionPrivate::xdvdfs_strcasecmp(const char *s1, const char *s2)
* @param filename Filename to find, without subdirectories.
* @return Pointer to XDVDFS_DirEntry within dirTable, or nullptr if not found.
*/
const XDVDFS_DirEntry *XDVDFSPartitionPrivate::getDirEntry(const ao::uvector<uint8_t> *dirTable, const char *filename)
const XDVDFS_DirEntry *XDVDFSPartitionPrivate::getDirEntry(const rp::uvector<uint8_t> *dirTable, const char *filename)
{
assert(dirTable != nullptr);
assert(filename != nullptr);
@ -244,9 +244,9 @@ const XDVDFS_DirEntry *XDVDFSPartitionPrivate::getDirEntry(const ao::uvector<uin
* Get the specified directory.
* This should *only* be the directory, not a filename.
* @param path Directory path.
* @return Pointer to directory table (ao::uvector), or nullptr if not found.
* @return Pointer to directory table (rp::uvector), or nullptr if not found.
*/
const ao::uvector<uint8_t> *XDVDFSPartitionPrivate::getDirectory(const char *path)
const rp::uvector<uint8_t> *XDVDFSPartitionPrivate::getDirectory(const char *path)
{
RP_Q(XDVDFSPartition);
if (unlikely(!path || path[0] != '/')) {
@ -300,7 +300,7 @@ const ao::uvector<uint8_t> *XDVDFSPartitionPrivate::getDirectory(const char *pat
}
// Read the directory.
ao::uvector<uint8_t> dirTable(dir_size);
rp::uvector<uint8_t> dirTable(dir_size);
size_t size = q->m_discReader->seekAndRead(dir_addr, dirTable.data(), dirTable.size());
if (size != dirTable.size()) {
// Seek and/or read error.
@ -543,7 +543,7 @@ IRpFilePtr XDVDFSPartition::open(const char *filename)
// TODO: Handle subdirectories.
// For now, assuming the file is in the root directory.
RP_D(XDVDFSPartition);
const ao::uvector<uint8_t> *const dirTable = d->getDirectory("/");
const rp::uvector<uint8_t> *const dirTable = d->getDirectory("/");
if (!dirTable) {
// Directory not found.
// getDirectory() has already set m_lastError.

View File

@ -67,8 +67,7 @@
#include "librpbase/RomData.hpp"
#include "librpbase/img/IconAnimData.hpp"
// Uninitialized vector class.
// Reference: http://andreoffringa.org/?q=uvector
// Uninitialized vector class
#include "uvector.h"
// librpbase DiscReader

View File

@ -40,8 +40,7 @@ using std::ostringstream;
using std::shared_ptr;
using std::string;
// Uninitialized vector class.
// Reference: http://andreoffringa.org/?q=uvector
// Uninitialized vector class
#include "uvector.h"
namespace LibRomData { namespace Tests {
@ -97,9 +96,9 @@ class RomHeaderTest : public ::testing::TestWithParam<RomHeaderTest_mode>
// NOTE: Not storing the source .tar filename.
// There shouldn't be any conflicts, though...
static string last_bin_filename;
static ao::uvector<uint8_t> last_bin_data;
static ao::uvector<uint8_t> last_txt_data;
static ao::uvector<uint8_t> last_json_data;
static rp::uvector<uint8_t> last_bin_data;
static rp::uvector<uint8_t> last_txt_data;
static rp::uvector<uint8_t> last_json_data;
/**
* Read the next set of files from the .tar files.
@ -136,9 +135,9 @@ forward_list<tar_files_t> RomHeaderTest::all_tar_files;
// NOTE: Not storing the source .tar filename.
// There shouldn't be any conflicts, though...
string RomHeaderTest::last_bin_filename;
ao::uvector<uint8_t> RomHeaderTest::last_bin_data;
ao::uvector<uint8_t> RomHeaderTest::last_txt_data;
ao::uvector<uint8_t> RomHeaderTest::last_json_data;
rp::uvector<uint8_t> RomHeaderTest::last_bin_data;
rp::uvector<uint8_t> RomHeaderTest::last_txt_data;
rp::uvector<uint8_t> RomHeaderTest::last_json_data;
/**
* Read the next set of files from the .tar files.

View File

@ -31,7 +31,7 @@ using LibRomData::GcnFst;
// libwin32common
#ifdef _WIN32
#include "libwin32common/RpWin32_sdk.h"
# include "libwin32common/RpWin32_sdk.h"
#endif
// FST printer
@ -52,8 +52,7 @@ using std::stringstream;
using std::unordered_set;
using std::vector;
// Uninitialized vector class.
// Reference: http://andreoffringa.org/?q=uvector
// Uninitialized vector class
#include "uvector.h"
namespace LibRomData { namespace Tests {
@ -117,12 +116,12 @@ class GcnFstTest : public ::testing::TestWithParam<GcnFstTest_mode>
*/
static int getFileFromZip(const char *zip_filename,
const char *int_filename,
ao::uvector<uint8_t>& buf,
rp::uvector<uint8_t>& buf,
uint64_t max_filesize = MAX_GCN_FST_BIN_FILESIZE);
public:
// FST data.
ao::uvector<uint8_t> m_fst_buf;
rp::uvector<uint8_t> m_fst_buf;
IFst *m_fst;
/**
@ -232,7 +231,7 @@ unzFile GcnFstTest::openZip(const char *filename)
*/
int GcnFstTest::getFileFromZip(const char *zip_filename,
const char *int_filename,
ao::uvector<uint8_t>& buf,
rp::uvector<uint8_t>& buf,
uint64_t max_filesize)
{
// Open the Zip file.
@ -428,7 +427,7 @@ TEST_P(GcnFstTest, FstPrint)
fst_txt_filename.replace(fst_txt_filename.size() - 8, 8, ".fst.txt");
// Get the known-good FST printout.
ao::uvector<uint8_t> fst_txt_buf;
rp::uvector<uint8_t> fst_txt_buf;
ASSERT_GT(getFileFromZip(zip_filename, fst_txt_filename.c_str(), fst_txt_buf, MAX_GCN_FST_TXT_FILESIZE), 0);
// Import the FST text into an istringstream.

View File

@ -26,8 +26,8 @@
(ZLIB_VER_MAJOR == 1 && ZLIB_VER_MINOR == 2 && ZLIB_VER_REVISION >= 4)
// zlib-1.2.4 or later
#else
#define gzclose_r(file) gzclose(file)
#define gzclose_w(file) gzclose(file)
# define gzclose_r(file) gzclose(file)
# define gzclose_w(file) gzclose(file)
#endif
// librpbase, librpfile
@ -69,8 +69,7 @@ using std::shared_ptr;
using std::string;
using std::unique_ptr;
// Uninitialized vector class.
// Reference: http://andreoffringa.org/?q=uvector
// Uninitialized vector class
#include "uvector.h"
namespace LibRomData { namespace Tests {
@ -164,8 +163,8 @@ class ImageDecoderTest : public ::testing::TestWithParam<ImageDecoderTest_mode>
public:
// Image buffers.
ao::uvector<uint8_t> m_dds_buf;
ao::uvector<uint8_t> m_png_buf;
rp::uvector<uint8_t> m_dds_buf;
rp::uvector<uint8_t> m_png_buf;
// gzip file handle for .dds.gz.
// Placed here so it can be freed by TearDown() if necessary.

View File

@ -20,8 +20,7 @@ using std::string;
using std::unique_ptr;
using std::unordered_map;
// Uninitialized vector class.
// Reference: http://andreoffringa.org/?q=uvector
// Uninitialized vector class
#include "uvector.h"
// zlib for CRC32.
@ -154,11 +153,11 @@ class AchievementsPrivate
// - 0x0FFFFFFF -> FF FF FF 7F
/**
* Append a uint64_t to an ao::uvector<> using varlenint format.
* @param vec ao::uvector<>
* Append a uint64_t to an rp::uvector<> using varlenint format.
* @param vec rp::uvector<>
* @param val Value
*/
static void appendVarlenInt(ao::uvector<uint8_t> &vec, uint64_t val);
static void appendVarlenInt(rp::uvector<uint8_t> &vec, uint64_t val);
/**
* Parse a varlenint value.
@ -252,11 +251,11 @@ AchievementsPrivate::AchievementsPrivate()
{ }
/**
* Append a uint64_t to an ao::uvector<> using varlenint format.
* @param vec ao::uvector<>
* Append a uint64_t to an rp::uvector<> using varlenint format.
* @param vec rp::uvector<>
* @param val Value
*/
void AchievementsPrivate::appendVarlenInt(ao::uvector<uint8_t> &vec, uint64_t val)
void AchievementsPrivate::appendVarlenInt(rp::uvector<uint8_t> &vec, uint64_t val)
{
vec.reserve(vec.size() + 8);
@ -366,7 +365,7 @@ int AchievementsPrivate::save(void) const
#endif /* defined(_MSC_VER) && defined(ZLIB_IS_DLL) */
// Create the achievements file in memory.
ao::uvector<uint8_t> buf;
rp::uvector<uint8_t> buf;
buf.reserve(sizeof(AchBinHeader) + ((int)Achievements::ID::Max * 12));
buf.resize(sizeof(AchBinHeader));
@ -536,7 +535,7 @@ int AchievementsPrivate::load(void)
return -ENOMEM;
}
ao::uvector<uint8_t> buf;
rp::uvector<uint8_t> buf;
buf.resize(static_cast<size_t>(fileSize));
size_t size = file->read(buf.data(), buf.size());
if (size != buf.size()) {

View File

@ -66,7 +66,7 @@ class ConfigPrivate : public ConfReaderPrivate
// Image type priority data.
// Managed as a single block in order to reduce
// memory allocations.
ao::uvector<uint8_t> vImgTypePrio;
rp::uvector<uint8_t> vImgTypePrio;
/**
* Map of RomData subclass names to vImgTypePrio indexes.

View File

@ -64,7 +64,7 @@ class KeyManagerPrivate : public ConfReaderPrivate
// Encryption key data.
// Managed as a single block in order to reduce
// memory allocations.
ao::uvector<uint8_t> vKeys;
rp::uvector<uint8_t> vKeys;
/**
* Map of key names to vKeys indexes.

View File

@ -24,14 +24,16 @@
(ZLIB_VER_MAJOR == 1 && ZLIB_VER_MINOR == 2 && ZLIB_VER_REVISION >= 4)
// zlib-1.2.4 or later
#else
#define gzclose_r(file) gzclose(file)
#define gzclose_w(file) gzclose(file)
# define gzclose_r(file) gzclose(file)
# define gzclose_w(file) gzclose(file)
#endif
#include "common.h"
#include "uvector.h"
#include "tcharx.h" // for DIR_SEP_CHR
// Uninitialized vector class
#include "uvector.h"
// Other rom-properties libraries
#include "librpcpu/byteswap_rp.h"
#include "librpfile/FileSystem.hpp"
@ -176,7 +178,7 @@ class RpPngFormatTest : public ::testing::TestWithParam<RpPngFormatTest_mode>
static void Load_Verify_BMP_headers(
BITMAPFILEHEADER *pBfh,
BITMAPINFOHEADER *pBih,
const ao::uvector<uint8_t> &bmp_buf);
const rp::uvector<uint8_t> &bmp_buf);
/**
* Compare an ARGB32 rp_image to a 24-bit RGB bitmap.
@ -268,8 +270,8 @@ class RpPngFormatTest : public ::testing::TestWithParam<RpPngFormatTest_mode>
public:
// Image buffers.
ao::uvector<uint8_t> m_png_buf;
ao::uvector<uint8_t> m_bmp_buf;
rp::uvector<uint8_t> m_png_buf;
rp::uvector<uint8_t> m_bmp_buf;
// gzip file handle for .bmp.gz.
// Placed here so it can be freed by TearDown() if necessary.
@ -430,7 +432,7 @@ void RpPngFormatTest::Load_Verify_IHDR(PNG_IHDR_t *ihdr, const uint8_t *ihdr_src
void RpPngFormatTest::Load_Verify_BMP_headers(
BITMAPFILEHEADER *pBfh,
BITMAPINFOHEADER *pBih,
const ao::uvector<uint8_t> &bmp_buf)
const rp::uvector<uint8_t> &bmp_buf)
{
static_assert(sizeof(BITMAPFILEHEADER) == BITMAPFILEHEADER_SIZE,
"BITMAPFILEHEADER size is incorrect. (should be 14 bytes)");

View File

@ -67,8 +67,7 @@ struct fsxattr {
# define O_LARGEFILE 0
#endif /* !O_LARGEFILE */
// Uninitialized vector class.
// Reference: http://andreoffringa.org/?q=uvector
// Uninitialized vector class
#include "uvector.h"
// C++ STL classes
@ -371,7 +370,7 @@ int XAttrReaderPrivate::loadGenericXattrs(void)
// Partially based on KIO's FileProtocol::copyXattrs().
// Reference: https://invent.kde.org/frameworks/kio/-/blob/584a81fd453858db432a573c011a1433bc6947e1/src/kioworkers/file/file_unix.cpp#L521
ssize_t listlen = 0;
ao::uvector<char> keylist;
rp::uvector<char> keylist;
keylist.reserve(256);
while (true) {
keylist.resize(listlen);
@ -416,7 +415,7 @@ int XAttrReaderPrivate::loadGenericXattrs(void)
#endif /* HAVE_SYS_XATTR_H */
// Value buffer
ao::uvector<char> value;
rp::uvector<char> value;
value.reserve(256);
// Linux, macOS: List contains NULL-terminated strings.

View File

@ -43,8 +43,7 @@ using std::string;
using std::unique_ptr;
using std::vector;
// Uninitialized vector class.
// Reference: http://andreoffringa.org/?q=uvector
// Uninitialized vector class
#include "uvector.h"
namespace LibRpTexture {
@ -76,7 +75,7 @@ class KhronosKTX2Private final : public FileFormatPrivate
rp_image::FlipOp flipOp;
// Mipmap offsets
ao::uvector<KTX2_Mipmap_Index> mipmap_data;
rp::uvector<KTX2_Mipmap_Index> mipmap_data;
// Decoded mipmaps
// Mipmap 0 is the full image.

View File

@ -474,8 +474,8 @@ rp_image_const_ptr SegaPVRPrivate::loadPvrImage(void)
break;
}
// SVR palette buffer.
ao::uvector<uint8_t> svr_pal_buf;
// SVR palette buffer
rp::uvector<uint8_t> svr_pal_buf;
// Determine the image size.
switch (pvrHeader.pvr.img_data_type) {

View File

@ -36,8 +36,7 @@ using namespace LibRpTexture;
#include <string>
using std::string;
// Uninitialized vector class.
// Reference: http://andreoffringa.org/?q=uvector
// Uninitialized vector class
#include "uvector.h"
namespace LibRpTexture { namespace Tests {
@ -115,8 +114,8 @@ class ImageDecoderLinearTest : public ::testing::TestWithParam<ImageDecoderLinea
public:
// Temporary image buffer
// 128x128 24-bit or 32-bit image data.
// FIXME: Use an aligned Allocator with ao::uvector<>.
//ao::uvector<uint8_t> m_img_buf;
// FIXME: Use an aligned Allocator with rp::uvector<>.
//rp::uvector<uint8_t> m_img_buf;
uint8_t *m_img_buf;
size_t m_img_buf_len;

View File

@ -44,7 +44,7 @@ size_t CurlDownloader::write_data(char *ptr, size_t size, size_t nmemb, void *us
// - http://stackoverflow.com/a/1636415
// - https://curl.haxx.se/libcurl/c/CURLOPT_WRITEFUNCTION.html
CurlDownloader *curlDL = static_cast<CurlDownloader*>(userdata);
ao::uvector<uint8_t> *vec = &curlDL->m_data;
rp::uvector<uint8_t> *vec = &curlDL->m_data;
const size_t len = size * nmemb;
if (curlDL->m_maxSize > 0) {
@ -84,7 +84,7 @@ size_t CurlDownloader::parse_header(char *ptr, size_t size, size_t nitems, void
// TODO: Add support for non-HTTP protocols?
CurlDownloader *curlDL = static_cast<CurlDownloader*>(userdata);
ao::uvector<uint8_t> *vec = &curlDL->m_data;
rp::uvector<uint8_t> *vec = &curlDL->m_data;
const size_t len = size * nitems;
// Supported headers.

View File

@ -18,8 +18,7 @@
#include <cstddef>
#include <ctime>
// Uninitialized vector class.
// Reference: http://andreoffringa.org/?q=uvector
// Uninitialized vector class
#include "uvector.h"
// tcharx
@ -139,7 +138,7 @@ class NOVTABLE IDownloader
// Uninitialized vector class.
// Reference: http://andreoffringa.org/?q=uvector
ao::uvector<uint8_t> m_data;
rp::uvector<uint8_t> m_data;
time_t m_mtime; // Last-Modified response
time_t m_if_modified_since; // If-Modified-Since request

File diff suppressed because it is too large Load Diff