summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2003-06-23 12:46:13 +0000
committerXavier Leroy <xavier.leroy@inria.fr>2003-06-23 12:46:13 +0000
commit37ea8fd4fde80cc306b71cd7f2b236378a87d9a5 (patch)
tree0f37d6781966b831e80674b7a4ee62379bebc4d8
parentd8e2ca67bc8a1980e8343cfc81791ae50e1c7f47 (diff)
Correction de obj_dup dans le cas ou le bloc a copier est >= Max_young_wosize
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5613 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--byterun/obj.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/byterun/obj.c b/byterun/obj.c
index f2b72de6b..73572dceb 100644
--- a/byterun/obj.c
+++ b/byterun/obj.c
@@ -15,6 +15,7 @@
/* Operations on objects */
+#include <string.h>
#include "alloc.h"
#include "fail.h"
#include "gc.h"
@@ -82,12 +83,17 @@ CAMLprim value obj_dup(value arg)
sz = Wosize_val(arg);
if (sz == 0) return arg;
-
tg = Tag_val(arg);
- res = alloc(sz, tg);
- for (i = 0; i < sz; i++)
- Field(res, i) = Field(arg, i);
-
+ if (tg >= No_scan_tag) {
+ res = alloc(sz, tg);
+ memcpy(Bp_val(res), Bp_val(arg), sz * sizeof(value));
+ } else if (sz <= Max_young_wosize) {
+ res = alloc_small(sz, tg);
+ for (i = 0; i < sz; i++) Field(res, i) = Field(arg, i);
+ } else {
+ res = alloc_shr(sz, tg);
+ for (i = 0; i < sz; i++) initialize(&Field(res, i), Field(arg, i));
+ }
CAMLreturn (res);
}