Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r289:6dd90df368c2
Date: 2013-06-26 18:31 +0200
http://bitbucket.org/pypy/stmgc/changeset/6dd90df368c2/

Log:    Untested, checked in in case it's needed later

diff --git a/c4/lists.c b/c4/lists.c
--- a/c4/lists.c
+++ b/c4/lists.c
@@ -129,6 +129,20 @@
   gcptrlist->alloc = 0;
 }
 
+void gcptrlist_compress(struct GcPtrList *gcptrlist)
+{
+  if (gcptrlist->alloc <= gcptrlist->size + 64)
+    return;
+
+  size_t nsize = gcptrlist->size * sizeof(gcptr);
+  gcptr *newitems = realloc(gcptrlist->items, nsize);
+  if (newitems != NULL || nsize == 0)
+    {
+      gcptrlist->items = newitems;
+      gcptrlist->alloc = gcptrlist->size;
+    }
+}
+
 void _gcptrlist_grow(struct GcPtrList *gcptrlist)
 {
   long newalloc = gcptrlist->alloc + (gcptrlist->alloc >> 1) + 64;
diff --git a/c4/lists.h b/c4/lists.h
--- a/c4/lists.h
+++ b/c4/lists.h
@@ -130,6 +130,7 @@
 }
 
 void gcptrlist_delete(struct GcPtrList *gcptrlist);
+void gcptrlist_compress(struct GcPtrList *gcptrlist);
 void _gcptrlist_grow(struct GcPtrList *gcptrlist);
 void gcptrlist_insert2(struct GcPtrList *gcptrlist, gcptr newitem1,
                        gcptr newitem2);
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to