summaryrefslogtreecommitdiff
path: root/byterun/obj.c
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2000-03-30 17:29:09 +0000
committerXavier Leroy <xavier.leroy@inria.fr>2000-03-30 17:29:09 +0000
commit7feb8382c4b29192ff451acb84631361eb4a0891 (patch)
treecff2e3b01a09e668e5d386ebac37ca0c35548abe /byterun/obj.c
parent7433ad92fc6656cd68c9ec6d4ef96b3edc6edb10 (diff)
downloadocaml-7feb8382c4b29192ff451acb84631361eb4a0891.tar.gz
Bug subtil de GC dans obj_truncate (PR#61)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3020 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'byterun/obj.c')
-rw-r--r--byterun/obj.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/byterun/obj.c b/byterun/obj.c
index e2e4dbc11d..f35fcf5033 100644
--- a/byterun/obj.c
+++ b/byterun/obj.c
@@ -100,9 +100,15 @@ value obj_truncate (value v, value newsize) /* ML */
tag_t tag = Tag_hd (hd);
color_t color = Color_hd (hd);
mlsize_t wosize = Wosize_hd (hd);
+ mlsize_t i;
- if (new_wosize <= 0 || new_wosize > wosize) invalid_argument ("Obj.truncate");
+ if (new_wosize <= 0 || new_wosize > wosize)
+ invalid_argument ("Obj.truncate");
if (new_wosize == wosize) return Val_unit;
+ /* PR#61: since we're about to lose our references to the elements
+ beyond new_wosize in v, erase them explicitly so that the GC
+ can darken them as appropriate. */
+ for (i = new_wosize; i < wosize; i++) modify(&Field(v, i), Val_unit);
Field (v, new_wosize) =
Make_header (Wosize_whsize (wosize-new_wosize), 0, Caml_white);
Hd_val (v) = Make_header (new_wosize, tag, color);