mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-21 07:20:28 -04:00
added a new method rs_malloc that checks its arguments and prints a stacktrace on error/weird call. Changed the code everywhere to use this instead of malloc. Removed some mallocs and replaced with RsTemporaryMemory
This commit is contained in:
parent
9c6e7dfc13
commit
d13526facd
39 changed files with 274 additions and 132 deletions
|
@ -33,6 +33,7 @@
|
|||
#include "util/rsdir.h"
|
||||
#include "util/rsstring.h"
|
||||
#include "util/rsrandom.h"
|
||||
#include "util/rsmemory.h"
|
||||
#include "retroshare/rstypes.h"
|
||||
#include "rsthreads.h"
|
||||
#include <iostream>
|
||||
|
@ -267,7 +268,14 @@ bool RsDirUtil::copyFile(const std::string& source,const std::string& dest)
|
|||
size_t T=0;
|
||||
|
||||
static const int BUFF_SIZE = 10485760 ; // 10 MB buffer to speed things up.
|
||||
void *buffer = malloc(BUFF_SIZE) ;
|
||||
RsTemporaryMemory buffer(BUFF_SIZE) ;
|
||||
|
||||
if(!buffer)
|
||||
{
|
||||
fclose(in) ;
|
||||
fclose(out) ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
bool bRet = true;
|
||||
|
||||
|
@ -286,8 +294,6 @@ bool RsDirUtil::copyFile(const std::string& source,const std::string& dest)
|
|||
fclose(in) ;
|
||||
fclose(out) ;
|
||||
|
||||
free(buffer) ;
|
||||
|
||||
return true ;
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue