From 98b3a4e168930943465212eca8b4fba122bc9e1f Mon Sep 17 00:00:00 2001 From: "Joakim L. Gilje" Date: Fri, 22 Nov 2013 10:28:49 +0100 Subject: [PATCH 1/5] Compiling on Windows using MinGW --- CMakeLists.txt | 7 ++++++- src/cql/cql_serialization.cpp | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b3445098d..bff60e918 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,7 +70,12 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") # -fPIC is not used on Windows platform (all DLLs are # relocable), -Wall generates about 30k stupid warnings # that can hide useful ones. - set(PLATFORM_DEPENDENT_COMPILER_OPTIONS "-D_CRT_SECURE_NO_WARNINGS") + if (${MSVC}) + set(PLATFORM_DEPENDENT_COMPILER_OPTIONS "-D_CRT_SECURE_NO_WARNINGS") + elseif (${MINGW}) + set(LIBS ${LIBS} ws2_32) + + endif() # needed for windows sockets (not verified) add_definitions(-D_WIN32_WINNT=0x0501) diff --git a/src/cql/cql_serialization.cpp b/src/cql/cql_serialization.cpp index 276687c78..fefb5f73b 100644 --- a/src/cql/cql_serialization.cpp +++ b/src/cql/cql_serialization.cpp @@ -33,7 +33,7 @@ using namespace std; inline double swap_double(double source) { -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__GNUC__) uint64_t bytes = *reinterpret_cast(&source); uint64_t swapped = _byteswap_uint64(bytes); return *reinterpret_cast(&swapped); @@ -50,7 +50,7 @@ swap_double(double source) { inline float swap_float(float source) { -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__GNUC__) uint32_t bytes = *reinterpret_cast(&source); uint32_t swapped = _byteswap_ulong(bytes); return *reinterpret_cast(&swapped); From 0336dcf12d8acd33a0be00d80b5406e02fe51fff Mon Sep 17 00:00:00 2001 From: "Joakim L. Gilje" Date: Tue, 26 Nov 2013 14:01:36 +0100 Subject: [PATCH 2/5] closed memory leak in cql_connection_impl_t::query, allocated cql::cql_message_query_impl_t was never deleted --- include/cql/internal/cql_connection_impl.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/cql/internal/cql_connection_impl.hpp b/include/cql/internal/cql_connection_impl.hpp index 07d5b675d..5301fb54c 100644 --- a/include/cql/internal/cql_connection_impl.hpp +++ b/include/cql/internal/cql_connection_impl.hpp @@ -229,7 +229,8 @@ class cql_connection_impl_t : public cql::cql_connection_t _callback_storage.set_callbacks(stream, callback_pair_t(callback, errback)); - create_request(new cql::cql_message_query_impl_t(query), + cql::cql_message_query_impl_t message(query); + create_request(&message, boost::bind(&cql_connection_impl_t::write_handle, this, boost::asio::placeholders::error, From 3716074df2f7561bde21558bbf79b6dd26f3c8e6 Mon Sep 17 00:00:00 2001 From: "Joakim L. Gilje" Date: Tue, 26 Nov 2013 14:21:32 +0100 Subject: [PATCH 3/5] similar memory leaks --- include/cql/internal/cql_connection_impl.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/cql/internal/cql_connection_impl.hpp b/include/cql/internal/cql_connection_impl.hpp index 5301fb54c..8ff27f2c4 100644 --- a/include/cql/internal/cql_connection_impl.hpp +++ b/include/cql/internal/cql_connection_impl.hpp @@ -255,8 +255,9 @@ class cql_connection_impl_t : public cql::cql_connection_t _callback_storage.set_callbacks(stream, callback_pair_t(callback, errback)); + cql::cql_message_prepare_impl_t message(query), create_request( - new cql::cql_message_prepare_impl_t(query), + &message, boost::bind(&cql_connection_impl_t::write_handle, this, boost::asio::placeholders::error, @@ -815,8 +816,9 @@ class cql_connection_impl_t : public cql::cql_connection_t void options_write() { + cql::cql_message_options_impl_t message(); create_request( - new cql::cql_message_options_impl_t(), + &message, (boost::function)boost::bind( &cql_connection_impl_t::write_handle, this, From 1e969887fee1c348b562d0ec6c25c77c97e0e825 Mon Sep 17 00:00:00 2001 From: "Joakim L. Gilje" Date: Thu, 2 Jan 2014 06:51:03 +0100 Subject: [PATCH 4/5] missing semi --- include/cql/internal/cql_connection_impl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/cql/internal/cql_connection_impl.hpp b/include/cql/internal/cql_connection_impl.hpp index 8ff27f2c4..9b880c994 100644 --- a/include/cql/internal/cql_connection_impl.hpp +++ b/include/cql/internal/cql_connection_impl.hpp @@ -255,7 +255,7 @@ class cql_connection_impl_t : public cql::cql_connection_t _callback_storage.set_callbacks(stream, callback_pair_t(callback, errback)); - cql::cql_message_prepare_impl_t message(query), + cql::cql_message_prepare_impl_t message(query); create_request( &message, boost::bind(&cql_connection_impl_t::write_handle, From 617fda01f2aad921328435e171399d1ac2fc7b77 Mon Sep 17 00:00:00 2001 From: "Joakim L. Gilje" Date: Thu, 2 Jan 2014 06:55:04 +0100 Subject: [PATCH 5/5] compile fix --- include/cql/internal/cql_connection_impl.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/cql/internal/cql_connection_impl.hpp b/include/cql/internal/cql_connection_impl.hpp index 9b880c994..8c4476f8d 100644 --- a/include/cql/internal/cql_connection_impl.hpp +++ b/include/cql/internal/cql_connection_impl.hpp @@ -816,9 +816,9 @@ class cql_connection_impl_t : public cql::cql_connection_t void options_write() { - cql::cql_message_options_impl_t message(); + std::auto_ptr m(new cql::cql_message_options_impl_t()); create_request( - &message, + m.release(), (boost::function)boost::bind( &cql_connection_impl_t::write_handle, this,