backend update from Raze
* moving large allocations off the stack * use proper printf formatters for size_t and ptrdiff_t. * adding some missing 'noexcept'.
This commit is contained in:
parent
df9b2cd9bf
commit
83aa9388ca
29 changed files with 117 additions and 109 deletions
|
|
@ -45,6 +45,7 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <memory>
|
||||
#include "ancientzip.h"
|
||||
|
||||
namespace FileSys {
|
||||
|
|
@ -342,10 +343,19 @@ int FZipExploder::Explode(unsigned char *out, unsigned int outsize,
|
|||
|
||||
int ShrinkLoop(unsigned char *out, unsigned int outsize, FileReader &_In, unsigned int InLeft)
|
||||
{
|
||||
// don't allocate this on the stack, it's a bit on the large side.
|
||||
struct work
|
||||
{
|
||||
unsigned char ReadBuf[256];
|
||||
unsigned short Parent[HSIZE];
|
||||
unsigned char Value[HSIZE], Stack[HSIZE];
|
||||
};
|
||||
auto s = std::make_unique<work>();
|
||||
unsigned char* ReadBuf = s->ReadBuf;
|
||||
unsigned short* Parent = s->Parent;
|
||||
unsigned char* Value = s->Value, * Stack = s->Stack;
|
||||
|
||||
FileReader *In = &_In;
|
||||
unsigned char ReadBuf[256];
|
||||
unsigned short Parent[HSIZE];
|
||||
unsigned char Value[HSIZE], Stack[HSIZE];
|
||||
unsigned char *newstr;
|
||||
int len;
|
||||
int KwKwK, codesize = 9; /* start at 9 bits/code */
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "resourcefile.h"
|
||||
#include "fs_filesystem.h"
|
||||
|
|
@ -415,7 +416,7 @@ void FileSystem::AddFile (const char *filename, FileReader *filer, LumpFilterInf
|
|||
snprintf(cksumout + (j * 2), 3, "%02X", cksum[j]);
|
||||
}
|
||||
|
||||
fprintf(hashfile, "file: %s, hash: %s, size: %d\n", filename, cksumout, (int)filereader.GetLength());
|
||||
fprintf(hashfile, "file: %s, hash: %s, size: %td\n", filename, cksumout, filereader.GetLength());
|
||||
}
|
||||
|
||||
else
|
||||
|
|
@ -434,7 +435,7 @@ void FileSystem::AddFile (const char *filename, FileReader *filer, LumpFilterInf
|
|||
snprintf(cksumout + (j * 2), 3, "%02X", cksum[j]);
|
||||
}
|
||||
|
||||
fprintf(hashfile, "file: %s, lump: %s, hash: %s, size: %llu\n", filename, resfile->getName(i), cksumout, (uint64_t)resfile->Length(i));
|
||||
fprintf(hashfile, "file: %s, lump: %s, hash: %s, size: %zu\n", filename, resfile->getName(i), cksumout, (uint64_t)resfile->Length(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1272,7 +1273,7 @@ void FileSystem::ReadFile (int lump, void *dest)
|
|||
|
||||
if (numread != size)
|
||||
{
|
||||
throw FileSystemException("W_ReadFile: only read %ld of %ld on '%s'\n",
|
||||
throw FileSystemException("W_ReadFile: only read %td of %td on '%s'\n",
|
||||
numread, size, FileInfo[lump].LongName);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ class StringPool
|
|||
friend class FileSystem;
|
||||
friend class FResourceFile;
|
||||
private:
|
||||
StringPool(bool _shared, size_t blocksize = 10*1024) : TopBlock(nullptr), FreeBlocks(nullptr), BlockSize(blocksize), shared(_shared) {}
|
||||
StringPool(bool _shared, size_t blocksize = 10*1024) : TopBlock(nullptr), BlockSize(blocksize), shared(_shared) {}
|
||||
public:
|
||||
~StringPool();
|
||||
const char* Strdup(const char*);
|
||||
|
|
@ -20,7 +20,6 @@ protected:
|
|||
Block *AddBlock(size_t size);
|
||||
|
||||
Block *TopBlock;
|
||||
Block *FreeBlocks;
|
||||
size_t BlockSize;
|
||||
public:
|
||||
bool shared;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue