Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix crash when use predictor in Android Library #11

Open
wants to merge 2 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
eigen/
3 changes: 3 additions & 0 deletions source/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
*.o
*.d
*.so
*.a
data/example_networks/imagenet.ntwk
10 changes: 6 additions & 4 deletions source/Android.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
LIBSRCS:=$(shell find src/lib -name '*.cpp')
LIBSRCS:=$(shell find src/lib -path src/lib/pi -prune -o -name '*.cpp' -print)
${info ${LIBSRCS}}
NDK_PATH := /Users/zhengzhiheng/android-ndk-r9d/
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(LIBSRCS)
Expand All @@ -14,10 +16,10 @@ LOCAL_C_INCLUDES += ./src/lib/include \
./src/lib \
./src/include \
../eigen \
/Users/petewarden/android_ndk/sources/cxx-stl/gnu-libstdc++/4.6/include \
/Users/petewarden/android_ndk/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include
$(NDK_PATH)/sources/cxx-stl/gnu-libstdc++/4.6/include \
$(NDK_PATH)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include

LOCAL_CFLAGS := -DUSE_EIGEN_GEMM -DUSE_NEON
LOCAL_CFLAGS := -DUSE_EIGEN_GEMM
LOCAL_CFLAGS += -mfloat-abi=softfp -mfpu=neon -march=armv7

LOCAL_CFLAGS += -fopenmp -O3
Expand Down
15 changes: 13 additions & 2 deletions source/src/lib/svm/svm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2681,7 +2681,13 @@ int svm_save_model(const char *model_file_name, const svm_model *model)

int svm_save_model_to_file_handle(FILE* fp, const svm_model* model) {

char *old_locale = strdup(setlocale(LC_ALL, NULL));
char *locale = setlocale(LC_ALL, NULL);
char *old_locale;
if (!locale)
old_locale = NULL;
else
old_locale = strdup(locale);

setlocale(LC_ALL, "C");

const svm_parameter& param = model->param;
Expand Down Expand Up @@ -2797,7 +2803,12 @@ svm_model *svm_load_model(const char *model_file_name)
FILE *fp = fopen(model_file_name,"rb");
if(fp==NULL) return NULL;

char *old_locale = strdup(setlocale(LC_ALL, NULL));
char *locale = setlocale(LC_ALL, NULL);
char *old_locale;
if (!locale)
old_locale = NULL;
else
old_locale = strdup(locale);
setlocale(LC_ALL, "C");

// read parameters
Expand Down