https://github.com/Unipisa/CMM
Revision c0f12bb6f3ea8f1350371695b42990a5c2eb93f2 authored by Giuseppe Attardi on 02 March 1998, 23:00:00 UTC, committed by CMM Curation Team on 11 December 2019, 14:35:48 UTC
Contributors mentioned in Changelog :
 - Giuseppe Attardi @attardi
 - Tito Flagella @tflagella
 - Pietro Iglio
1 parent 55778ad
Raw File
Tip revision: c0f12bb6f3ea8f1350371695b42990a5c2eb93f2 authored by Giuseppe Attardi on 02 March 1998, 23:00:00 UTC
1.9 -
Tip revision: c0f12bb
test6.cpp
/*
 * Test for arrays built with CmmVarObject in TempHeap
 */

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

class Item : public CmmObject 
{
  int x;
  Item *y;
public:
  void test() { printf("Testing ... OK\n") ; }
  void traverse() { Cmm::heap->scavenge((CmmObject **)&y); }
};

void
main()
{
  CmmHeap *tempHeap = new TempHeap(100000);

  //  Instead of 
  //  .... items = new Item[100];
  //  Use ....
  Item *items = (Item *) new (sizeof(Item) * 100, tempHeap) CmmVarObject;

  items[2].test();

  Cmm::heap->collect();

  items[2].test();
}
back to top