Skip to content

Commit

Permalink
Win32 compile fixes (replace nonstandard runtime-sized auto arrays wi…
Browse files Browse the repository at this point in the history
…th alloca)
  • Loading branch information
emfrias committed Oct 5, 2015
1 parent dacdb99 commit 2b2dfc6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,10 @@ target_include_directories(fc
)

#target_link_libraries( fc PUBLIC udt ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${ECC_LIB} )
target_link_libraries( fc PUBLIC -L/usr/local/lib udt ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${readline_libraries} ${ECC_LIB} )
IF(NOT WIN32)
set(LINK_USR_LOCAL_LIB -L/usr/local/lib)
ENDIF()
target_link_libraries( fc PUBLIC ${LINK_USR_LOCAL_LIB} udt ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${readline_libraries} ${ECC_LIB} )

if(MSVC)
set_source_files_properties( src/network/http/websocket.cpp PROPERTIES COMPILE_FLAGS "/bigobj" )
Expand Down
8 changes: 7 additions & 1 deletion src/crypto/elliptic_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
#include <fc/crypto/openssl.hpp>
#include <fc/crypto/ripemd160.hpp>

#ifdef _MSC_VER
# include <malloc.h>
#else
# include <alloca.h>
#endif

/* stuff common to all ecc implementations */

#define BTC_EXT_PUB_MAGIC (0x0488B21E)
Expand Down Expand Up @@ -225,7 +231,7 @@ namespace fc { namespace ecc {

static fc::string _to_base58( const extended_key_data& key )
{
char buffer[key.size() + 4];
char *buffer = (char*)alloca(key.size() + 4);
memcpy( buffer, key.begin(), key.size() );
fc::sha256 double_hash = fc::sha256::hash( fc::sha256::hash( key.begin(), key.size() ));
memcpy( buffer + key.size(), double_hash.data(), 4 );
Expand Down
10 changes: 8 additions & 2 deletions src/crypto/elliptic_secp256k1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
#include <assert.h>
#include <secp256k1.h>

#ifdef _MSC_VER
# include <malloc.h>
#else
# include <alloca.h>
#endif

#include "_elliptic_impl_priv.hpp"

namespace fc { namespace ecc {
Expand Down Expand Up @@ -183,7 +189,7 @@ namespace fc { namespace ecc {
{
if ( *in & 0x80 )
{
unsigned char buffer[len + 1];
unsigned char *buffer = (unsigned char*)alloca(len + 1);
*buffer = 0;
memcpy( buffer + 1, in, len );
BN_bin2bn( buffer, sizeof(buffer), out );
Expand All @@ -204,7 +210,7 @@ namespace fc { namespace ecc {
unsigned int l = BN_num_bytes( in );
if ( l > len )
{
unsigned char buffer[l];
unsigned char *buffer = (unsigned char*)alloca(l);
BN_bn2bin( in, buffer );
memcpy( out, buffer + l - len, len );
}
Expand Down

0 comments on commit 2b2dfc6

Please sign in to comment.