aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_binary.h
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2017-04-11 16:28:12 +0200
committerSverker Eriksson <[email protected]>2017-04-11 16:28:12 +0200
commit486a758ef245effab01d880493a0274de49c1797 (patch)
treea506758099a76c92b429f070f3e80b9932c5e916 /erts/emulator/beam/erl_binary.h
parent37bdfb3b5b56c2311db1780b052b7e2c0f139cef (diff)
downloadotp-486a758ef245effab01d880493a0274de49c1797.tar.gz
otp-486a758ef245effab01d880493a0274de49c1797.tar.bz2
otp-486a758ef245effab01d880493a0274de49c1797.zip
erts: Introduce erts_bin_release
Diffstat (limited to 'erts/emulator/beam/erl_binary.h')
-rw-r--r--erts/emulator/beam/erl_binary.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/erts/emulator/beam/erl_binary.h b/erts/emulator/beam/erl_binary.h
index 51072f4b0f..eb3f6dfb3b 100644
--- a/erts/emulator/beam/erl_binary.h
+++ b/erts/emulator/beam/erl_binary.h
@@ -316,6 +316,7 @@ ERTS_GLB_INLINE Binary *erts_bin_nrml_alloc(Uint size);
ERTS_GLB_INLINE Binary *erts_bin_realloc_fnf(Binary *bp, Uint size);
ERTS_GLB_INLINE Binary *erts_bin_realloc(Binary *bp, Uint size);
ERTS_GLB_INLINE void erts_bin_free(Binary *bp);
+ERTS_GLB_INLINE void erts_bin_release(Binary *bp);
ERTS_GLB_INLINE Binary *erts_create_magic_binary_x(Uint size,
int (*destructor)(Binary *),
ErtsAlcType_t alloc_type,
@@ -469,6 +470,14 @@ erts_bin_free(Binary *bp)
erts_free(ERTS_ALC_T_BINARY, (void *) bp);
}
+ERTS_GLB_INLINE void
+erts_bin_release(Binary *bp)
+{
+ if (erts_refc_dectest(&bp->refc, 0) == 0) {
+ erts_bin_free(bp);
+ }
+}
+
ERTS_GLB_INLINE Binary *
erts_create_magic_binary_x(Uint size, int (*destructor)(Binary *),
ErtsAlcType_t alloc_type,