This is an automated email from the ASF dual-hosted git repository. big-r81 pushed a commit to branch fix/nif_init in repository https://gitbox.apache.org/repos/asf/couchdb-snappy.git
commit dfccbf675468c8d9e12ac29dfc92a03135890783 Author: Ronny Berndt <[email protected]> AuthorDate: Fri Jun 12 18:35:35 2026 +0200 Simplify NIF loading 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) ->
