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

Allow to customize fz_store_size in Java bindings #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

max-kammerer
Copy link

No description provided.

Copy link
Contributor

@robinwatts robinwatts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, if I build a MuPDF library with FZ_STORE_DEFAULT_SIZE_IN_MB defined, it'll make no difference to anyone that uses that library, as they won't have that defined when they include context.h, so they'll get the default value.

If people want to use a different value for the store, they should state it explicitly. That is the purpose of this field after all!

If your intent is to allow runtime definition of the store size used in the java bindings, then that's not unreasonable, but I don't think you need the include/mupdf/fitz/context.h changes for that.

@max-kammerer
Copy link
Author

max-kammerer commented Dec 14, 2024

Hi @robinwatts! Yes, my main case is to allow runtime definitions of the store size in java bindings and it's covered by change in context.c. But I can use this scenario only with Android 5+, as Android allows to set env variables on runtime just starting from Android 5.
For Android 4.x devices I need another way to override default value and I came up with static solution passing FZ_STORE_DEFAULT_SIZE_IN_MB during compilation as I build mupdf library during application build.

@robinwatts
Copy link
Contributor

Leave the definition of FZ_STORE_DEFAULT alone.

In the Java code:

#ifdef FZ_JAVA_STORE_SIZE
size_t fz_store_size = FZ_JAVA_STORE_SIZE;
#else
size_t fz_store_size = FZ_STORE_DEFAULT;
#endif
char *env_fz_store_size = getenv("FZ_JAVA_STORE_SIZE");
if (env_fz_store_size)
fz_store_size = atol(env_fz_store_size);
base_context = fz_new_context(NULL, &locks, fz_store_size);

That way you can predefine FZ_JAVA_STORE_SIZE when you build the java bindings, or you can use the same environment variable. Don't mess around with specifying it in MB.

@max-kammerer max-kammerer changed the title Allow to customize FZ_STORE_DEFAULT during compilation and runtime Allow to customize fz_store_size in Java bindings Dec 15, 2024
@max-kammerer
Copy link
Author

@robinwatts Thank you! Updated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants