From 440a04a8d9587f19574a95187c5b38496706decd Mon Sep 17 00:00:00 2001 From: Raymond Toy <toy.raymond@gmail.com> Date: Wed, 26 Dec 2012 14:10:04 -0800 Subject: [PATCH] Fix bitrot: support scavenging unicode strings.. --- src/lisp/gc.c | 45 ++++++++++++++++----------------------------- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/src/lisp/gc.c b/src/lisp/gc.c index dc75e1515..6af7a153e 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 -- GitLab