https://github.com/Unipisa/CMM
Raw File
Tip revision: c0f12bb6f3ea8f1350371695b42990a5c2eb93f2 authored by Giuseppe Attardi on 02 March 1998, 23:00:00 UTC
1.9 -
Tip revision: c0f12bb
test8.cpp
// Contributed by Christian Heckler <chh@plato.uni-paderborn.de>
// This tests the MARKING algorithm when objects have pointers to later
// objects in the page.

#include "cmm.h"
#include <stdio.h>

const int length=100000;

class TestClass: public CmmObject
{
 public:
  int data;
  TestClass *next;
  void traverse();
};

void TestClass::traverse()
{
  Cmm::heap->scavenge((CmmObject **)&next);
}

typedef TestClass* Classptr;

void createlist(Classptr p)
{
  int i;

  for (i = 0; i < length; i++)
    {
      p = p->next = new TestClass;
      if (i % 10000 == 0)
	{ printf("|"); fflush(stdout); }
      else if (i % 1000 == 0)
	printf(".");
    }
  p->next = NULL;
}

void
main()
{
  Classptr p0;
  p0 = new TestClass;
  createlist(p0);
  printf("\n");
}
back to top