[svn:parrot] r43379 - in branches/pmc_freeze_cleanup: include/parrot src/string

plobsing at svn.parrot.org plobsing at svn.parrot.org
Mon Jan 4 05:38:10 UTC 2010


Author: plobsing
Date: Mon Jan  4 05:38:09 2010
New Revision: 43379
URL: https://trac.parrot.org/parrot/changeset/43379

Log:
Null buffer after making a string out of it in Parrot_str_new_from_buffer.
This is needed to not confuse GC during string compaction.

Modified:
   branches/pmc_freeze_cleanup/include/parrot/string_funcs.h
   branches/pmc_freeze_cleanup/src/string/api.c

Modified: branches/pmc_freeze_cleanup/include/parrot/string_funcs.h
==============================================================================
--- branches/pmc_freeze_cleanup/include/parrot/string_funcs.h	Sun Jan  3 21:23:28 2010	(r43378)
+++ branches/pmc_freeze_cleanup/include/parrot/string_funcs.h	Mon Jan  4 05:38:09 2010	(r43379)
@@ -294,10 +294,11 @@
 PARROT_MALLOC
 PARROT_CANNOT_RETURN_NULL
 STRING * Parrot_str_new_from_buffer(PARROT_INTERP,
-    ARGIN(const Buffer *buffer),
+    ARGMOD(Buffer *buffer),
     const UINTVAL len)
         __attribute__nonnull__(1)
-        __attribute__nonnull__(2);
+        __attribute__nonnull__(2)
+        FUNC_MODIFIES(*buffer);
 
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT

Modified: branches/pmc_freeze_cleanup/src/string/api.c
==============================================================================
--- branches/pmc_freeze_cleanup/src/string/api.c	Sun Jan  3 21:23:28 2010	(r43378)
+++ branches/pmc_freeze_cleanup/src/string/api.c	Mon Jan  4 05:38:09 2010	(r43379)
@@ -653,10 +653,12 @@
 
 /*
 
-=item C<STRING * Parrot_str_new_from_buffer(PARROT_INTERP, const Buffer *buffer,
-const UINTVAL len)>
+=item C<STRING * Parrot_str_new_from_buffer(PARROT_INTERP, Buffer *buffer, const
+UINTVAL len)>
 
-Make a Parrot string from a Buffer
+Make a Parrot string from a Buffer.
+
+The Buffer is nulled afterwards - only one PObj can point at a given string pool object.
 
 =cut
 
@@ -667,7 +669,7 @@
 PARROT_MALLOC
 PARROT_CANNOT_RETURN_NULL
 STRING *
-Parrot_str_new_from_buffer(PARROT_INTERP, ARGIN(const Buffer *buffer), const UINTVAL len)
+Parrot_str_new_from_buffer(PARROT_INTERP, ARGMOD(Buffer *buffer), const UINTVAL len)
 {
     ASSERT_ARGS(Parrot_str_new_from_buffer)
     STRING *result;
@@ -681,6 +683,9 @@
     result->encoding        = Parrot_fixed_8_encoding_ptr;
     result->charset         = Parrot_binary_charset_ptr;
 
+    Buffer_bufstart(buffer) = NULL;
+    Buffer_buflen(buffer)   = 0;
+
     return result;
 }
 


More information about the parrot-commits mailing list