# New Ticket Created by  Steve Fink 
# Please include the string:  [perl #16859]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=16859 >


This patch is the real fix for strings with the BUFFER_external_FLAG.
It requires the previous dod.c and resources.c patches to be applied.

Strings marked with the BUFFER_external_FLAG point to the external
memory rather than making a copy for themselves. Side effects of this
are (1) less memory usage, (2) external updates to the string are
reflected in the Parrot STRING (except for length changes!), and (3)
these strings are skipped over when memory is getting moved around
during a compaction.


-- attachment  1 ------------------------------------------------------
url: http://rt.perl.org/rt2/attach/36052/29178/90822c/external-strings.patch

Index: string.c
===================================================================
RCS file: /cvs/public/parrot/string.c,v
retrieving revision 1.90
diff -p -u -r1.90 string.c
--- string.c    23 Aug 2002 07:53:35 -0000      1.90
+++ string.c    29 Aug 2002 20:27:23 -0000
@@ -182,13 +182,25 @@ string_make(struct Parrot_Interp *interp
     }
 
     s = new_string_header(interpreter, flags);
-    Parrot_allocate_string(interpreter, s, buflen);
+    if (flags & BUFFER_external_FLAG) {
+        s->bufstart = buffer;
+        s->buflen = buflen;
+    }
+    else {
+        Parrot_allocate_string(interpreter, s, buflen);
+    }
     s->encoding = encoding;
     s->type = type;
 
     if (buffer) {
-        mem_sys_memcopy(s->strstart, buffer, buflen);
-        s->bufused = buflen;
+        if (flags & BUFFER_external_FLAG) {
+            s->strstart = s->bufstart;
+            s->bufused = buflen;
+        }
+        else {
+            mem_sys_memcopy(s->strstart, buffer, buflen);
+            s->bufused = buflen;
+        }
         (void)string_compute_strlen(s);
     }
     else {

Reply via email to