diff --git a/src/lisp/gc.c b/src/lisp/gc.c index dc75e1515e745af7f4c875a0a974e89518e534f2..6af7a153e6efca708de79b98b377b97118b6408d 100644 --- a/src/lisp/gc.c +++ b/src/lisp/gc.c @@ -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