diff options
author | Björn Gustavsson <[email protected]> | 2012-11-21 12:09:04 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2012-11-26 11:12:59 +0100 |
commit | 556879a3d8c4dfa611b9c2444b9e9e77b9ec4e49 (patch) | |
tree | c4f10f16c65662626d9d5084bf96d6e5ff3d1e40 /lib/asn1/src/asn1rt_ber_bin_v2.erl | |
parent | 649df4292bc8c425c52cba3657547251ef78254f (diff) | |
download | otp-556879a3d8c4dfa611b9c2444b9e9e77b9ec4e49.tar.gz otp-556879a3d8c4dfa611b9c2444b9e9e77b9ec4e49.tar.bz2 otp-556879a3d8c4dfa611b9c2444b9e9e77b9ec4e49.zip |
Don't try to work around a non-loadable NIF library
The NIF library is now mandatory.
The call to application:get_env/2 to find out whether the NIF
library is loaded is surprisingly expensive.
Diffstat (limited to 'lib/asn1/src/asn1rt_ber_bin_v2.erl')
-rw-r--r-- | lib/asn1/src/asn1rt_ber_bin_v2.erl | 36 |
1 files changed, 4 insertions, 32 deletions
diff --git a/lib/asn1/src/asn1rt_ber_bin_v2.erl b/lib/asn1/src/asn1rt_ber_bin_v2.erl index e46e163ebb..92ca11cf89 100644 --- a/lib/asn1/src/asn1rt_ber_bin_v2.erl +++ b/lib/asn1/src/asn1rt_ber_bin_v2.erl @@ -53,8 +53,6 @@ decode_open_type_as_binary/3]). -export([decode_primitive_incomplete/2,decode_selective/2]). - --export([is_nif_loadable/0]). % the encoding of class of tag bits 8 and 7 -define(UNIVERSAL, 0). @@ -134,12 +132,7 @@ encode(Tlv,_) when is_binary(Tlv) -> encode([Tlv],Method) -> encode(Tlv,Method); encode(Tlv, nif) -> - case is_nif_loadable() of - true -> - asn1rt_nif:encode_ber_tlv(Tlv); - false -> - encode_erl(Tlv) - end; + asn1rt_nif:encode_ber_tlv(Tlv); encode(Tlv, _) -> encode_erl(Tlv). @@ -177,36 +170,15 @@ decode(B) -> %% asn1-1.7 decode(B, nif) -> - case is_nif_loadable() of - true -> - case asn1rt_nif:decode_ber_tlv(B) of - {error, Reason} -> handle_error(Reason, B); - Else -> Else - end; - false -> - decode(B) + case asn1rt_nif:decode_ber_tlv(B) of + {error, Reason} -> handle_error(Reason, B); + Else -> Else end; decode(B,erlang) when is_binary(B) -> decode_primitive(B); decode(Tlv,erlang) -> {Tlv,<<>>}. -%% Have to check this since asn1 is not guaranteed to be available -is_nif_loadable() -> - case application:get_env(asn1, nif_loadable) of - {ok,R} -> - R; - undefined -> - case catch code:load_file(asn1rt_nif) of - {module, asn1rt_nif} -> - application:set_env(asn1, nif_loadable, true), - true; - _Else -> - application:set_env(asn1, nif_loadable, false), - false - end - end. - handle_error([],_)-> exit({error,{asn1,{"memory allocation problem"}}}); handle_error({$1,_},L) -> % error in nif |