diff --git a/src/stralloc.c b/src/stralloc.c
index 5be68f0af80547db5774973552c4891fa56d3234..a38128b8c0d6736af1c9cedc344371cbd431fd78 100644
--- a/src/stralloc.c
+++ b/src/stralloc.c
@@ -15,7 +15,7 @@
 
 #include <ctype.h>
 
-RCSID("$Id: stralloc.c,v 1.41 1998/10/11 21:07:30 grubba Exp $");
+RCSID("$Id: stralloc.c,v 1.42 1998/10/11 22:34:02 hubbe Exp $");
 
 #define BEGIN_HASH_SIZE 997
 #define MAX_AVG_LINK_LENGTH 3
@@ -1071,18 +1071,21 @@ struct pike_string *modify_shared_string(struct pike_string *a,
 	b=begin_wide_shared_string(a->len,1);
 	convert_0_to_1(STR1(b),a->str,a->len);
 	STR1(b)[index]=c;
+	free_string(a);
 	return end_shared_string(b);
 
       case TWO_SIZES(2,0):
 	b=begin_wide_shared_string(a->len,2);
 	convert_0_to_2(STR2(b),a->str,a->len);
 	STR2(b)[index]=c;
+	free_string(a);
 	return end_shared_string(b);
 
       case TWO_SIZES(2,1):
 	b=begin_wide_shared_string(a->len,2);
 	convert_1_to_2(STR2(b),STR1(a),a->len);
 	STR2(b)[index]=c;
+	free_string(a);
 	return end_shared_string(b);
 
       default:
@@ -1535,6 +1538,13 @@ void string_builder_shared_strcat(struct string_builder *s, struct pike_string *
   s->s->len+=str->len;
 }
 
+
+void reset_string_builder(struct string_builder *s)
+{
+  s->known_shift=0;
+  s->s->len=0;
+}
+
 struct pike_string *finish_string_builder(struct string_builder *s)
 {
   low_set_index(s->s,s->s->len,0);
diff --git a/src/stralloc.h b/src/stralloc.h
index f37cddd9170e2029210922e9fc5cae1b72a20ffb..a410faabcb53297a805dddcab5410314cb574b1d 100644
--- a/src/stralloc.h
+++ b/src/stralloc.h
@@ -5,7 +5,7 @@
 \*/
 
 /*
- * $Id: stralloc.h,v 1.19 1998/10/11 11:18:53 hubbe Exp $
+ * $Id: stralloc.h,v 1.20 1998/10/11 22:34:02 hubbe Exp $
  */
 #ifndef STRALLOC_H
 #define STRALLOC_H
@@ -182,6 +182,7 @@ void string_builder_putchar(struct string_builder *s, int ch);
 void string_builder_binary_strcat(struct string_builder *s, char *str, INT32 len);
 void string_builder_strcat(struct string_builder *s, char *str);
 void string_builder_shared_strcat(struct string_builder *s, struct pike_string *str);
+void reset_string_builder(struct string_builder *s);
 struct pike_string *finish_string_builder(struct string_builder *s);
 /* Prototypes end here */