mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-29 08:37:36 -04:00
removed two instances of malloc(0) captured by new rs_malloc funtion
This commit is contained in:
parent
d13526facd
commit
d55993d1e4
35 changed files with 73 additions and 56 deletions
|
@ -43,7 +43,7 @@ bool RsCompress::compress_memory_chunk(const uint8_t *input_mem,const uint32_t i
|
|||
uint32_t output_offset = 0 ;
|
||||
uint32_t input_offset = 0 ;
|
||||
output_size = 1024 ;
|
||||
output_mem = (uint8_t*)rs_safe_malloc(output_size) ;
|
||||
output_mem = (uint8_t*)rs_malloc(output_size) ;
|
||||
|
||||
if(!output_mem)
|
||||
return false ;
|
||||
|
@ -117,7 +117,7 @@ bool RsCompress::uncompress_memory_chunk(const uint8_t *input_mem,const uint32_t
|
|||
output_size = input_size ;
|
||||
uint32_t output_offset = 0 ;
|
||||
uint32_t input_offset = 0 ;
|
||||
output_mem = (uint8_t*)rs_safe_malloc(output_size) ;
|
||||
output_mem = (uint8_t*)rs_malloc(output_size) ;
|
||||
|
||||
if(!output_mem)
|
||||
return false ;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "util/rsmemory.h"
|
||||
|
||||
void *rs_safe_malloc(size_t size)
|
||||
void *rs_malloc(size_t size)
|
||||
{
|
||||
static const size_t SAFE_MEMALLOC_THRESHOLD = 1024*1024*1024 ; // 1Gb should be enough for everything!
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <iostream>
|
||||
#include <util/stacktrace.h>
|
||||
|
||||
void *rs_safe_malloc(size_t size) ;
|
||||
void *rs_malloc(size_t size) ;
|
||||
|
||||
// This is a scope guard to release the memory block when going of of the current scope.
|
||||
// Can be very useful to auto-delete some memory on quit without the need to call free each time.
|
||||
|
@ -28,7 +28,7 @@ class RsTemporaryMemory
|
|||
public:
|
||||
RsTemporaryMemory(size_t s)
|
||||
{
|
||||
_mem = (unsigned char *)rs_safe_malloc(s) ;
|
||||
_mem = (unsigned char *)rs_malloc(s) ;
|
||||
|
||||
if(_mem)
|
||||
_size = s ;
|
||||
|
|
|
@ -207,7 +207,7 @@ SmallObjectAllocator::~SmallObjectAllocator()
|
|||
void *SmallObjectAllocator::allocate(size_t bytes)
|
||||
{
|
||||
if(bytes > _maxObjectSize)
|
||||
return rs_safe_malloc(bytes) ;
|
||||
return rs_malloc(bytes) ;
|
||||
else if(_lastAlloc != NULL && _lastAlloc->blockSize() == bytes)
|
||||
return _lastAlloc->allocate() ;
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue