diff options
author | Sverker Eriksson <[email protected]> | 2017-10-16 17:56:46 +0200 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2017-10-17 15:26:20 +0200 |
commit | 890fb3bc90cdab64506cd4a43ca0a04727b5b7ea (patch) | |
tree | 649cb79c0a8c614979f5feb995899c2c097aa805 /erts/doc | |
parent | f0695a70cdaa4fe0fc0e7c58fb791483af0efa1a (diff) | |
download | otp-890fb3bc90cdab64506cd4a43ca0a04727b5b7ea.tar.gz otp-890fb3bc90cdab64506cd4a43ca0a04727b5b7ea.tar.bz2 otp-890fb3bc90cdab64506cd4a43ca0a04727b5b7ea.zip |
erts: Add 'used' option to binary_to_term/2
Diffstat (limited to 'erts/doc')
-rw-r--r-- | erts/doc/src/erlang.xml | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/erts/doc/src/erlang.xml b/erts/doc/src/erlang.xml index 2465f49581..a83ae3eb4b 100644 --- a/erts/doc/src/erlang.xml +++ b/erts/doc/src/erlang.xml @@ -549,9 +549,7 @@ hello <name name="binary_to_term" arity="2"/> <fsummary>Decode an Erlang external term format binary.</fsummary> <desc> - <p>As <c>binary_to_term/1</c>, but takes options that affect decoding - of the binary.</p> - <p>Option:</p> + <p>As <c>binary_to_term/1</c>, but takes these options:</p> <taglist> <tag><c>safe</c></tag> <item> @@ -567,18 +565,31 @@ hello creation of new external function references. None of those resources are garbage collected, so unchecked creation of them can exhaust available memory.</p> - </item> - </taglist> - <p>Failure: <c>badarg</c> if <c>safe</c> is specified and unsafe - data is decoded.</p> <pre> -> <input>binary_to_term(<<131,100,0,5,104,101,108,108,111>>, [safe]).</input> +> <input>binary_to_term(<<131,100,0,5,"hello">>, [safe]).</input> ** exception error: bad argument > <input>hello.</input> hello -> <input>binary_to_term(<<131,100,0,5,104,101,108,108,111>>, [safe]).</input> +> <input>binary_to_term(<<131,100,0,5,"hello">>, [safe]).</input> hello </pre> + </item> + <tag><c>used</c></tag> + <item> + <p>Changes the return value to <c>{Term, Used}</c> where <c>Used</c> + is the number of bytes actually read from <c>Binary</c>.</p> + <pre> +> <input>Input = <<131,100,0,5,"hello","world">>.</input> +<<131,100,0,5,104,101,108,108,111,119,111,114,108,100>> +> <input>{Term, Used} = binary_to_term(Input, [used]).</input> +{hello, 9} +> <input>split_binary(Input, Used).</input> +{<<131,100,0,5,104,101,108,108,111>>, <<"world">>} +</pre> + </item> + </taglist> + <p>Failure: <c>badarg</c> if <c>safe</c> is specified and unsafe + data is decoded.</p> <p>See also <seealso marker="#term_to_binary/1"><c>term_to_binary/1</c></seealso>, <seealso marker="#binary_to_term/1"> |