Fix bitrot: support scavenging unicode strings..
authorRaymond Toy <toy.raymond@gmail.com>
Wed, 26 Dec 2012 22:10:04 +0000 (14:10 -0800)
committerRaymond Toy <toy.raymond@gmail.com>
Wed, 26 Dec 2012 22:10:04 +0000 (14:10 -0800)
src/lisp/gc.c

index dc75e15..6af7a15 100644 (file)
@@ -1202,7 +1202,7 @@ size_unboxed(lispobj * where)
 #define NWORDS(x,y) (CEILING((x),(y)) / (y))
 
 static int
-scav_string(lispobj * where, lispobj object)
+size_string(lispobj * where)
 {
     struct vector *vector;
     int length, nwords;
@@ -1212,43 +1212,30 @@ scav_string(lispobj * where, lispobj object)
 
     vector = (struct vector *) where;
     length = fixnum_value(vector->length) + 1;
+#ifndef UNICODE
     nwords = CEILING(NWORDS(length, 4) + 2, 2);
+#else
+    /*
+     * Strings are just like arrays with 16-bit elements, and contain
+     * one more element than the slot length indicates.
+     */
+    nwords = CEILING(NWORDS(length, 2) + 2, 2);
+#endif
 
     return nwords;
 }
 
-static lispobj
-trans_string(lispobj object)
+static int
+scav_string(lispobj * where, lispobj object)
 {
-    struct vector *vector;
-    int length, nwords;
-
-    gc_assert(Pointerp(object));
-
-    /* NOTE: Strings contain one more byte of data than the length */
-    /* slot indicates. */
-
-    vector = (struct vector *) PTR(object);
-    length = fixnum_value(vector->length) + 1;
-    nwords = CEILING(NWORDS(length, 4) + 2, 2);
-
-    return copy_object(object, nwords);
+    return size_string(where);
 }
 
-static int
-size_string(lispobj * where)
+static lispobj
+trans_string(lispobj object)
 {
-    struct vector *vector;
-    int length, nwords;
-
-    /* NOTE: Strings contain one more byte of data than the length */
-    /* slot indicates. */
-
-    vector = (struct vector *) where;
-    length = fixnum_value(vector->length) + 1;
-    nwords = CEILING(NWORDS(length, 4) + 2, 2);
-
-    return nwords;
+    gc_assert(Pointerp(object));
+    return copy_object(object, size_string((lispobj *) PTR(object)));
 }
 
 static int