Skip to content

Instantly share code, notes, and snippets.

Created September 8, 2010 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/570226 to your computer and use it in GitHub Desktop.
Save anonymous/570226 to your computer and use it in GitHub Desktop.
Index: src/pmc/stringbuilder.pmc
===================================================================
--- src/pmc/stringbuilder.pmc (revision 48855)
+++ src/pmc/stringbuilder.pmc (working copy)
@@ -165,6 +165,8 @@
if (STRING_IS_NULL(s))
return;
+ Parrot_block_GC_mark(interp);
+
GET_ATTR_buffer(INTERP, SELF, buffer);
if (buffer->bufused == 0) {
@@ -190,22 +192,8 @@
STRING * new_buffer;
new_buffer = Parrot_utf8_encoding_ptr->to_encoding(interp, buffer);
- total_size = new_buffer->bufused + s->bufused;
-
- if (total_size > buffer->_buflen) {
- /* Reallocate */
- mem_gc_free(INTERP, buffer->_bufstart);
- total_size = calculate_capacity(INTERP, total_size);
- buffer->_bufstart = buffer->strstart
- = mem_gc_allocate_n_typed(INTERP, total_size, char);
- buffer->_buflen = total_size;
- }
-
- buffer->bufused = new_buffer->bufused;
- buffer->encoding = new_buffer->encoding;
-
- mem_sys_memcopy(buffer->strstart, new_buffer->strstart,
- new_buffer->bufused);
+ buffer = new_buffer;
+ SET_ATTR_buffer(INTERP, SELF, buffer);
}
}
}
@@ -231,6 +219,8 @@
buffer->strlen += Parrot_str_length(INTERP, s);
buffer->hashval = 0; /* hash is invalid */
+ Parrot_unblock_GC_mark(interp);
+
PARROT_ASSERT(buffer->bufused <= Buffer_buflen(buffer));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment