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
master
Xavier Leroy 2003-06-23 12:46:13 +00:00
parent d8e2ca67bc
commit 37ea8fd4fd
1 changed files with 11 additions and 5 deletions

View File

@ -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);
}