Skip to content

Commit

Permalink
Merge pull request #19 from graeme-hill/android-mem-leak
Browse files Browse the repository at this point in the history
Android mem leak
  • Loading branch information
graeme-hill authored Jun 18, 2017
2 parents d440d94 + 8da099b commit ef91787
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
35 changes: 19 additions & 16 deletions Guid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,23 +350,26 @@ Guid newGuid()

std::array<unsigned char, 16> bytes =
{
(mostSignificant >> 56) & 0xFF,
(mostSignificant >> 48) & 0xFF,
(mostSignificant >> 40) & 0xFF,
(mostSignificant >> 32) & 0xFF,
(mostSignificant >> 24) & 0xFF,
(mostSignificant >> 16) & 0xFF,
(mostSignificant >> 8) & 0xFF,
(mostSignificant) & 0xFF,
(leastSignificant >> 56) & 0xFF,
(leastSignificant >> 48) & 0xFF,
(leastSignificant >> 40) & 0xFF,
(leastSignificant >> 32) & 0xFF,
(leastSignificant >> 24) & 0xFF,
(leastSignificant >> 16) & 0xFF,
(leastSignificant >> 8) & 0xFF,
(leastSignificant) & 0xFF,
(unsigned char)((mostSignificant >> 56) & 0xFF),
(unsigned char)((mostSignificant >> 48) & 0xFF),
(unsigned char)((mostSignificant >> 40) & 0xFF),
(unsigned char)((mostSignificant >> 32) & 0xFF),
(unsigned char)((mostSignificant >> 24) & 0xFF),
(unsigned char)((mostSignificant >> 16) & 0xFF),
(unsigned char)((mostSignificant >> 8) & 0xFF),
(unsigned char)((mostSignificant) & 0xFF),
(unsigned char)((leastSignificant >> 56) & 0xFF),
(unsigned char)((leastSignificant >> 48) & 0xFF),
(unsigned char)((leastSignificant >> 40) & 0xFF),
(unsigned char)((leastSignificant >> 32) & 0xFF),
(unsigned char)((leastSignificant >> 24) & 0xFF),
(unsigned char)((leastSignificant >> 16) & 0xFF),
(unsigned char)((leastSignificant >> 8) & 0xFF),
(unsigned char)((leastSignificant) & 0xFF)
};

androidInfo.env->DeleteLocalRef(javaUuid);

return bytes;
}
#endif
Expand Down
8 changes: 4 additions & 4 deletions Guid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ THE SOFTWARE.

#pragma once

#ifdef GUID_ANDROID
#include <jni.h>
#endif

#include <functional>
#include <iostream>
#include <array>
Expand All @@ -32,10 +36,6 @@ THE SOFTWARE.
#include <utility>
#include <iomanip>

#ifdef GUID_ANDROID
#include <jni.h>
#endif

#define BEGIN_XG_NAMESPACE namespace xg {
#define END_XG_NAMESPACE }

Expand Down
3 changes: 2 additions & 1 deletion android/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ LOCAL_MODULE := crossguidtest
LOCAL_CFLAGS := -Wall
LOCAL_SRC_FILES := ../../Guid.cpp ../../test/Test.cpp jnitest.cpp
LOCAL_CPP_FLAGS := -std=c++14
LOCAL_CPPFLAGS := -DGUID_ANDROID -Wno-c++11-extensions
LOCAL_CPPFLAGS := -DGUID_ANDROID -Wno-c++11-extensions -Wno-missing-braces
LOCAL_LDLIBS := -latomic

include $(BUILD_SHARED_LIBRARY)
2 changes: 1 addition & 1 deletion android/jni/Application.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
APP_STL := stlport_static
APP_STL := c++_static
NDK_TOOLCHAIN_VERSION := clang
LOCAL_CPP_FLAGS := -DGUID_ANDROID
APP_ABI := all
2 changes: 1 addition & 1 deletion test/TestMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

int main()
{
return test(std::cout);
return test(std::cout);
}

0 comments on commit ef91787

Please sign in to comment.