[svn:parrot] r48386 - branches/unshared_buffers/src/string/encoding

darbelo at svn.parrot.org darbelo at svn.parrot.org
Tue Aug 10 21:02:47 UTC 2010


Author: darbelo
Date: Tue Aug 10 21:02:47 2010
New Revision: 48386
URL: https://trac.parrot.org/parrot/changeset/48386

Log:
Make ucs2 not depend on str_new.

Modified:
   branches/unshared_buffers/src/string/encoding/ucs2.c

Modified: branches/unshared_buffers/src/string/encoding/ucs2.c
==============================================================================
--- branches/unshared_buffers/src/string/encoding/ucs2.c	Tue Aug 10 21:02:34 2010	(r48385)
+++ branches/unshared_buffers/src/string/encoding/ucs2.c	Tue Aug 10 21:02:47 2010	(r48386)
@@ -314,11 +314,20 @@
 {
     ASSERT_ARGS(get_codepoints)
 #if PARROT_HAS_ICU
-    return Parrot_str_new_init(interp, (char *)Buffer_bufstart(s) + offs * sizeof (UChar),
-        count * sizeof (UChar), s->encoding, s->charset, PObj_get_FLAGS(s));
+    const UINTVAL flags = PObj_get_FLAGS(s) & ~PObj_external_FLAG;
+    STRING * const dst  = Parrot_gc_new_string_header(interp, flags);
+
+    dst->encoding = s->encoding;
+    dst->charset  = s->charset;
+    dst->strlen   = count;
+    dst->bufused  = count * sizeof (UChar);
+    Parrot_gc_allocate_string_storage(interp, dst, count);
+    mem_sys_memcopy(Buffer_bufstart(dst), Buffer_bufstart(s) + offs * sizeof (UChar),
+       count * sizeof (UChar));
+    return dst;
 #else
     UNUSED(s);
-    UNUSED(offset);
+    UNUSED(offs);
     UNUSED(count);
     no_ICU_lib(interp);
 #endif


More information about the parrot-commits mailing list