aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_bif_binary.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2018-01-16 15:02:26 +0100
committerSverker Eriksson <[email protected]>2018-01-16 15:02:26 +0100
commitb02208125f27b20e6ce186afcdc6b79e24ac732a (patch)
treed882dcccfee7cdd7faf0a4172758d2303732ec16 /erts/emulator/beam/erl_bif_binary.c
parent0841f405cdce1392a4d8975618c4e0895eb8a6b7 (diff)
parentf0123ff032ea2f9b4aa30322ad476e3f79757e79 (diff)
downloadotp-b02208125f27b20e6ce186afcdc6b79e24ac732a.tar.gz
otp-b02208125f27b20e6ce186afcdc6b79e24ac732a.tar.bz2
otp-b02208125f27b20e6ce186afcdc6b79e24ac732a.zip
Merge branch 'sverker/build-proc-bin'
Diffstat (limited to 'erts/emulator/beam/erl_bif_binary.c')
-rw-r--r--erts/emulator/beam/erl_bif_binary.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/erts/emulator/beam/erl_bif_binary.c b/erts/emulator/beam/erl_bif_binary.c
index 4cafa499a9..41c2ae08d3 100644
--- a/erts/emulator/beam/erl_bif_binary.c
+++ b/erts/emulator/beam/erl_bif_binary.c
@@ -2825,28 +2825,21 @@ BIF_RETTYPE binary_copy_trap(BIF_ALIST_2)
BIF_TRAP2(&binary_copy_trap_export, BIF_P, BIF_ARG_1, BIF_ARG_2);
} else {
Binary *save;
- ProcBin* pb;
+ Eterm resbin;
Uint target_size = cbs->result->orig_size;
while (pos < target_size) {
memcpy(t+pos,cbs->source, size);
pos += size;
}
- save = cbs->result;
+ save = cbs->result;
cbs->result = NULL;
cleanup_copy_bin_state(mb); /* now cbs is dead */
- pb = (ProcBin *) HAlloc(BIF_P, PROC_BIN_SIZE);
- pb->thing_word = HEADER_PROC_BIN;
- pb->size = target_size;
- pb->next = MSO(BIF_P).first;
- MSO(BIF_P).first = (struct erl_off_heap_header*) pb;
- pb->val = save;
- pb->bytes = t;
- pb->flags = 0;
-
- OH_OVERHEAD(&(MSO(BIF_P)), target_size / sizeof(Eterm));
- BUMP_REDS(BIF_P,(pos - opos) / BINARY_COPY_LOOP_FACTOR);
-
- BIF_RET(make_binary(pb));
+
+ resbin = erts_build_proc_bin(&MSO(BIF_P),
+ HAlloc(BIF_P, PROC_BIN_SIZE),
+ save);
+ BUMP_REDS(BIF_P,(pos - opos) / BINARY_COPY_LOOP_FACTOR);
+ BIF_RET(resbin);
}
}