Skip to content

Commit

Permalink
Initial commit that doesn't link
Browse files Browse the repository at this point in the history
  • Loading branch information
Irina Guberman committed Oct 28, 2015
1 parent ba49561 commit 1968f72
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions erts/emulator/beam/bif.tab
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ bif binary:encode_unsigned/1
bif binary:encode_unsigned/2
bif binary:decode_unsigned/1
bif binary:decode_unsigned/2
bif binary:free_refc_bin/1

bif erlang:nif_error/1
bif erlang:nif_error/2
Expand Down
14 changes: 12 additions & 2 deletions erts/emulator/beam/erl_bif_binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ static BMData *create_bmdata(MyAllocator *my, byte *x, Uint len,
/*
* Aho Corasick - Build a Trie and fill in the failure functions
* when all strings are added.
* The algorithm is nicely described by Dieter Bühler of University of
* Tübingen:
* The algorithm is nicely described by Dieter B�hler of University of
* T�bingen:
* http://www-sr.informatik.uni-tuebingen.de/~buehler/AC/AC.html
*/

Expand Down Expand Up @@ -2558,6 +2558,16 @@ BIF_RETTYPE binary_referenced_byte_size_1(BIF_ALIST_1)
BIF_RET(res);
}

BIF_RETTYPE free_refc_bin_1(BIF_ALIST_1)
{
if (is_binary(BIF_ARG_1) && binary_bitsize(BIF_ARG_1) > 512) {
erts_bin_free((Binary *) binary_val(BIF_ARG_1));
BIF_RET(am_true);
}
BIF_RET(am_false); /* this is a heap binary */
}


#define END_BIG 0
#define END_SMALL 1

Expand Down
8 changes: 7 additions & 1 deletion lib/stdlib/src/binary.erl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
decode_unsigned/2, encode_unsigned/1, encode_unsigned/2,
first/1, last/1, list_to_bin/1, longest_common_prefix/1,
longest_common_suffix/1, match/2, match/3, matches/2,
matches/3, part/2, part/3, referenced_byte_size/1]).
matches/3, part/2, part/3, referenced_byte_size/1, free_refc_bin/1]).

-spec at(Subject, Pos) -> byte() when
Subject :: binary(),
Expand Down Expand Up @@ -198,6 +198,12 @@ part(_, _, _) ->
referenced_byte_size(_) ->
erlang:nif_error(undef).

-spec free_refc_bin(Binary) -> boolean() when
Binary :: binary().

free_refc_bin(_) ->
erlang:nif_error(undef).

%%% End of BIFs.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down

0 comments on commit 1968f72

Please sign in to comment.