This is an automated email from the ASF dual-hosted git repository.
big-r81 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb-snappy.git
The following commit(s) were added to refs/heads/main by this push:
new 77ed2f9 Simplify NIF loading (#24)
77ed2f9 is described below
commit 77ed2f92a403cabe0687ea26baa9c57f67925911
Author: Ronny Berndt <[email protected]>
AuthorDate: Fri Jun 12 18:44:01 2026 +0200
Simplify NIF loading (#24)
Let's make it like other nifs do.
Thanks Nick for the hints!
---
src/snappy.erl | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/src/snappy.erl b/src/snappy.erl
index 7d3d36a..3764202 100644
--- a/src/snappy.erl
+++ b/src/snappy.erl
@@ -22,22 +22,16 @@
init() ->
- SoName = case code:priv_dir(?MODULE) of
- {error, bad_name} ->
- case filelib:is_dir(filename:join(["..", "priv"])) of
- true ->
- filename:join(["..", "priv", "snappy_nif"]);
- false ->
- filename:join(["priv", "snappy_nif"])
- end;
- Dir ->
- filename:join(Dir, "snappy_nif")
- end,
- (catch erlang:load_nif(SoName, 0)),
- case erlang:system_info(otp_release) of
- "R13B03" -> true;
- _ -> ok
- end.
+ PrivDir =
+ case code:priv_dir(?MODULE) of
+ {error, _} ->
+ EbinDir = filename:dirname(code:which(?MODULE)),
+ AppPath = filename:dirname(EbinDir),
+ filename:join(AppPath, "priv");
+ Path ->
+ Path
+ end,
+ erlang:load_nif(filename:join(PrivDir, "snappy_nif"), 0).
compress(_IoList) ->