From be3b87f65732fbdd8d86ec81f18616c8f4dfc324 Mon Sep 17 00:00:00 2001 From: fadedreamz Date: Sun, 12 Feb 2017 01:49:20 -0500 Subject: [PATCH] memory allocation failure temporary fix, with a small memory leask for unmapping the mapped file, updated vs build file Signed-off-by: fadedreamz --- crypto777/OS_portable.h | 4 ++++ crypto777/iguana_OS.c | 4 ++++ iguana.vcxproj | 8 ++++---- iguana/iguana_ramchain.c | 3 --- includes/iguana_defines.h | 3 ++- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/crypto777/OS_portable.h b/crypto777/OS_portable.h index d1baed4e0..540abd5e1 100755 --- a/crypto777/OS_portable.h +++ b/crypto777/OS_portable.h @@ -365,8 +365,12 @@ void escape_code(char *escaped,char *str); void SaM_PrepareIndices(); // iguana_serdes.c +#ifndef IGUANA_LOG2PACKETSIZE #define IGUANA_LOG2PACKETSIZE 22 +#endif +#ifndef IGUANA_MAXPACKETSIZE #define IGUANA_MAXPACKETSIZE (1 << IGUANA_LOG2PACKETSIZE) +#endif struct iguana_msghdr { uint8_t netmagic[4]; char command[12]; uint8_t serdatalen[4],hash[4]; } PACKED; int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp); diff --git a/crypto777/iguana_OS.c b/crypto777/iguana_OS.c index 5363f2135..cbc4e0c87 100755 --- a/crypto777/iguana_OS.c +++ b/crypto777/iguana_OS.c @@ -658,7 +658,11 @@ int64_t OS_copyfile(char *src,char *dest,int32_t cmpflag) { if ( (destfp= fopen(OS_compatible_path(dest),"wb")) != 0 ) { +#ifdef WIN32 + allocsize = 1024 * 1024 * 8L; +#else allocsize = 1024 * 1024 * 128L; +#endif buf = mycalloc('F',1,allocsize); while ( (len= fread(buf,1,allocsize,srcfp)) > 0 ) if ( (long)fwrite(buf,1,len,destfp) != len ) diff --git a/iguana.vcxproj b/iguana.vcxproj index 290de16b1..e7a0d7a57 100644 --- a/iguana.vcxproj +++ b/iguana.vcxproj @@ -90,7 +90,7 @@ Level2 Disabled - _CRT_SECURE_NO_WARNINGS;NATIVE_WINDOWS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;NATIVE_WINDOWS;WIN32;_DEBUG;_CONSOLE;IGUANA_LOG2PACKETSIZE=20;IGUANA_MAXPACKETSIZE=1572864;%(PreprocessorDefinitions) 1Byte .\iguana;%(AdditionalIncludeDirectories) @@ -107,7 +107,7 @@ Level3 Disabled - _DEBUG;_CONSOLE;NATIVE_WINDOWS;WIN32;%(PreprocessorDefinitions) + _DEBUG;_CONSOLE;NATIVE_WINDOWS;WIN32;IGUANA_LOG2PACKETSIZE=20;IGUANA_MAXPACKETSIZE=1572864;%(PreprocessorDefinitions) 1Byte @@ -125,7 +125,7 @@ MaxSpeed true true - _CRT_SECURE_NO_WARNINGS;NATIVE_WINDOWS;WIN32;_CONSOLE;NDEBUG;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;NATIVE_WINDOWS;WIN32;_CONSOLE;NDEBUG;IGUANA_LOG2PACKETSIZE=20;IGUANA_MAXPACKETSIZE=1572864;%(PreprocessorDefinitions) 1Byte @@ -145,7 +145,7 @@ MaxSpeed true true - WIN64;_WIN64;_CRT_SECURE_NO_WARNINGS;NATIVE_WINDOWS;WIN32;_CONSOLE;NDEBUG;%(PreprocessorDefinitions) + WIN64;_WIN64;_CRT_SECURE_NO_WARNINGS;NATIVE_WINDOWS;WIN32;_CONSOLE;NDEBUG;IGUANA_LOG2PACKETSIZE=20;IGUANA_MAXPACKETSIZE=1572864;%(PreprocessorDefinitions) 1Byte MultiThreaded diff --git a/iguana/iguana_ramchain.c b/iguana/iguana_ramchain.c index 7ed8867fc..6f02973c3 100755 --- a/iguana/iguana_ramchain.c +++ b/iguana/iguana_ramchain.c @@ -2188,9 +2188,6 @@ void iguana_bundlemapfree(struct iguana_info *coin,struct OS_memspace *mem,struc { for (j=starti; j<=endi; j++) { - //printf("R[%d]\n",j); - R[j].fileptr = 0; - R[j].filesize = 0; iguana_ramchain_free(coin,&R[j],1); } myfree(R,n * sizeof(*R)); diff --git a/includes/iguana_defines.h b/includes/iguana_defines.h index 333c517fb..ba7e106cb 100755 --- a/includes/iguana_defines.h +++ b/includes/iguana_defines.h @@ -62,8 +62,9 @@ #define IGUANA_LOG2MAXPEERS 11 // cant exceed 13 bits as ramchain unspents has bitfield #define IGUANA_MAXPEERS (1 << IGUANA_LOG2MAXPEERS) +#ifndef IGUANA_MAXPACKETSIZE #define IGUANA_MAXPACKETSIZE (1 << IGUANA_LOG2PACKETSIZE) - +#endif //#define IGUANA_MAXFILEITEMS 8192 #define IGUANA_RECENTPEER (3600 * 24 * 7)