applied removal of realloc to other files in file_sharing/ directory

This commit is contained in:
csoler 2016-11-25 20:05:23 +01:00
parent 0cb7778ceb
commit 5fbc263a36
4 changed files with 38 additions and 20 deletions

View file

@ -353,8 +353,12 @@ void HashStorage::locked_save()
bool HashStorage::readHashStorageInfo(const unsigned char *data,uint32_t total_size,uint32_t& offset,HashStorageInfo& info) const
{
unsigned char *section_data = NULL ;
uint32_t section_size = 0;
unsigned char *section_data = (unsigned char *)rs_malloc(FL_BASE_TMP_SECTION_SIZE) ;
if(!section_data)
return false ;
uint32_t section_size = FL_BASE_TMP_SECTION_SIZE;
uint32_t section_offset = 0;
// This way, the entire section is either read or skipped. That avoids the risk of being stuck somewhere in the middle
@ -375,9 +379,13 @@ bool HashStorage::readHashStorageInfo(const unsigned char *data,uint32_t total_s
bool HashStorage::writeHashStorageInfo(unsigned char *& data,uint32_t& total_size,uint32_t& offset,const HashStorageInfo& info) const
{
unsigned char *section_data = NULL ;
unsigned char *section_data = (unsigned char *)rs_malloc(FL_BASE_TMP_SECTION_SIZE) ;
if(!section_data)
return false ;
uint32_t section_offset = 0 ;
uint32_t section_size = 0;
uint32_t section_size = FL_BASE_TMP_SECTION_SIZE;
if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_FILE_NAME ,info.filename )) return false ;
if(!FileListIO::writeField(section_data,section_size,section_offset,FILE_LIST_IO_TAG_FILE_SIZE ,info.size )) return false ;