mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-13 09:52:01 -04:00
fix issue reported by msvc memory sanitiser
This commit is contained in:
parent
075100d2ce
commit
14d1a4666d
3 changed files with 7 additions and 11 deletions
|
@ -1386,7 +1386,7 @@ void enc_close(TMPFILE_RD *fil)
|
|||
int load_string_list_ex(TSTR_LIST *list,const char *filename)
|
||||
{
|
||||
char c[1024],*p;
|
||||
int i,j,lin=0;
|
||||
int i=0,j,lin=0;
|
||||
TMPFILE_RD *f;
|
||||
|
||||
f=enc_open(filename);
|
||||
|
|
|
@ -385,7 +385,7 @@ const void *load_mob_legacy_format(const void *p, int32_t *s) {
|
|||
nx = offsetof(TMOB, dialog_flags);
|
||||
memmove(d, c, nx - ofs);
|
||||
c+=nx - ofs -1; //second padding 1
|
||||
d+=nx;
|
||||
d+=nx-ofs;
|
||||
ofs=nx;
|
||||
nx = sizeof(TMOB);
|
||||
memmove(d, c, nx - ofs - 1); //last padding 1
|
||||
|
|
|
@ -11,11 +11,11 @@ extern "C" {
|
|||
}
|
||||
|
||||
typedef struct _temp_storage_file_wr {
|
||||
std::vector<uint8_t> *_data;
|
||||
std::string *_data;
|
||||
} TMPFILE_WR;
|
||||
|
||||
typedef struct _temp_storage_file_rd {
|
||||
std::basic_string_view<uint8_t> _data;
|
||||
std::string_view _data;
|
||||
int skp = 0;
|
||||
} TMPFILE_RD;
|
||||
|
||||
|
@ -31,7 +31,7 @@ struct icompare {
|
|||
}
|
||||
};
|
||||
|
||||
using FileSystem = std::map<std::string, std::vector<uint8_t>, icompare >;
|
||||
using FileSystem = std::map<std::string, std::string, icompare >;
|
||||
static FileSystem temp_fsystem;
|
||||
|
||||
|
||||
|
@ -40,8 +40,6 @@ void temp_storage_store(const char *name, const void *data, int32_t size) {
|
|||
auto e = b+size;
|
||||
auto &v =temp_fsystem[std::string(name)];
|
||||
v.clear();
|
||||
v.resize(size+1);
|
||||
v[size] = 0;
|
||||
v.resize(size);
|
||||
std::copy(b,e, v.begin());
|
||||
}
|
||||
|
@ -74,9 +72,7 @@ void temp_storage_clear() {
|
|||
TMPFILE_RD* temp_storage_open(const char *name) {
|
||||
auto iter = temp_fsystem.find(std::string_view(name));
|
||||
if (iter == temp_fsystem.end()) return NULL;
|
||||
iter->second.push_back(0); //put extra zero at the end
|
||||
iter->second.resize(iter->second.size()-1);
|
||||
return new TMPFILE_RD{std::basic_string_view<uint8_t>(iter->second.data(), iter->second.size())};
|
||||
return new TMPFILE_RD{{iter->second.c_str(), iter->second.size()}};
|
||||
}
|
||||
|
||||
TMPFILE_WR* temp_storage_create(const char *name) {
|
||||
|
@ -164,5 +160,5 @@ int temp_storage_internal_end_scanf(TMPFILE_RD *f, int r) {
|
|||
}
|
||||
|
||||
void temp_storage_ungetc(TMPFILE_RD *f) {
|
||||
f->_data = std::basic_string_view<uint8_t>(f->_data.data()-1, f->_data.size()+1);
|
||||
f->_data = {f->_data.data()-1, f->_data.size()+1};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue