Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/Unipisa/CMM
13 July 2022, 09:41:13 UTC
  • Code
  • Branches (2)
  • Releases (8)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/SourceCode
    • refs/heads/master
    • 1.9
    • 1.8
    • 1.7
    • 1.6
    • 1.5
    • 1.4
    • 1.3
    • 1.1
  • db1a798
  • /
  • base
  • /
  • testmsw3.cpp
Raw File Download
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
  • release
origin badgecontent badge Iframe embedding
swh:1:cnt:9a2114441746e66602ec2a842cfa5818128de0e3
origin badgedirectory badge Iframe embedding
swh:1:dir:b41dddd2eb7b13f8b7199d566241be68c78a83ab
origin badgerevision badge
swh:1:rev:55778ad8b99c136e1886959c1f1333c776df14e1
origin badgesnapshot badge
swh:1:snp:4ac4ed834489429d51fc0fd004f10ddbf78d807a
origin badgerelease badge
swh:1:rel:a6a00f689665e8e5b730fb4706b03c463146259a
Citations

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
  • release
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: 55778ad8b99c136e1886959c1f1333c776df14e1 authored by Giuseppe Attardi on 15 May 1997, 06:24:54 UTC
1.8 -
Tip revision: 55778ad
testmsw3.cpp
/* Test program for the MSW Heap */

/* Externals */

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

#define	VECT_SIZE	1000

struct  cell : CmmObject 
{
  cell  *car;
  cell  *cdr;
  int  value;
  cell(cell *initcar, cell *initcdr, int initvalue);
  void traverse();
};

typedef  cell* CP;

void cell::traverse()  
{
  CmmHeap *heap = Cmm::heap;
  heap->scavenge((CmmObject **)&car);
  heap->scavenge((CmmObject **)&cdr);
}


cell::cell(cell *initcar, cell *initcdr, int initvalue)
{
  car = initcar;
  cdr = initcdr;
  value = initvalue;
}

struct vector : CmmObject 
{
  vector  *car;
  vector  *cdr;
  int  value1;
  char bytes[VECT_SIZE];
  int  value2;
  vector(vector* x, vector* y, int v1, int v2);
};

typedef  vector* VP;


vector::vector(vector* x, vector* y, int v1, int v2)  
{
  car = x;
  cdr = y;
  value1 = v1;
  value2 = v2;
}

/* Test program */

int  init_global = 2,
array_global[VECT_SIZE];

void  printtree(CP zp)
{
  CP  tp;

  tp = zp;
  while  (tp != NULL)  
    {
      printf("%x: %d  ", tp, tp->value);
      tp = tp->cdr;
    }
  printf("\n");
  tp = zp;
  while  (tp != NULL)  
    {
      printf("%x: %d  ", tp, tp->value);
      tp = tp->car;
    }
  printf("\n");
}

void  listtest1()
{
  int  i, j;
  CP  lp, zp;
  
  printf("List test 1\n");
  lp = NULL;
  for (i = 0; i <= VECT_SIZE ; i++)  
    {
      if  (i % 15 != 14)
	printf("%d ", i);
      else
	printf("%d\n", i);
      zp = new cell(NULL, lp, i);
      lp = zp;
      Cmm::heap->collect();
      zp = lp;
      for (j = i; j >= 0 ; j--)  
	{
	  if ((zp == NULL) || (zp->value != j))
	    printf("LP is not a good list when j = %d\n", j);
	  zp = zp->cdr;
	}
    }
  printf("\n");		   
}

void  vectortest()
{
  int  i, j;
  VP  lp, zp;
  
  printf("Vector test\n");
  lp = NULL;
  for (i = 0; i <= 100 ; i++)  
    {
      if  (i % 15 != 14)
		printf("%d ", i);
	else
		printf("%d\n", i);
      zp = new vector(NULL, lp, i, i);
      lp = zp;
      Cmm::heap->collect();
      zp = lp;
      for (j = i; j >= 0 ; j--) {
	  // mswCheckAllocatedObj(zp);
	  // if (zp->cdr) mswCheckAllocatedObj(zp->cdr);
	
	  if ((zp == NULL) || (zp->value1 != j)  ||  (zp->value2 != j))
	    printf("LP is not a good list when j = %d\n", j);
	  zp = zp->cdr;
	  }
	}
  printf("\n");		   
}

CP  treetest()
{
  int  i;
  CP  tp, zp;

  printf("Tree test\n");
  tp = new cell(NULL, NULL, 0);
  for (i = 1; i <= 5; i++)  
    {
      zp = new cell(tp, tp, i);
      tp = zp;
    }
  Cmm::heap->collect();
  mswCheckHeap(1);
  zp = new cell(tp, tp, 6);
  Cmm::heap->collect();
  mswCheckHeap(1);
  printtree(zp);
  return(zp);
}

void  listtest2()
{
  int  i, j, length = 10000, repeat = 1000;
  CP  lp, zp;

  printf("List Test 2\n");
  for (i = 0; i < repeat; i++)  
    {
      if  (i % 15 != 14)
	printf("%d ", i);
      else {
	printf("%d\n", i);
        /* Cmm::heap->collect(); */
	 mswCheckHeap(0);
      }
      /* Build the list */
      lp = NULL;
      for  (j = 0; j < length; j++)  
	{
	  zp = new cell(NULL, lp, j);
	  lp = zp;
	}
      /* Check the list */
      zp = lp;
      for (j = length-1; j >= 0 ; j--)  
	{
	  // mswCheckAllocatedObj(zp);
	  // if (zp->cdr) mswCheckAllocatedObj(zp->cdr);

	  if ((zp == NULL) || (zp->value != j))
	    printf("LP is not a good list when j = %d\n", j);
	  zp = zp->cdr;
	}
    }
  printf("\n");		   
}

CP  gp;		/* A global pointer */

void
main()
{
  Cmm::heap = Cmm::theMSHeap;
  /* List construction test */
  /* printf("WARNING: skipping listtest1()!\n"); */
  listtest1();
  mswCheckHeap(1);

  /* List of vectors > 1 page */
  vectortest();
  mswCheckHeap(1);

  /* Tree construction test */
  gp = treetest();
  mswCheckHeap(1);

  /* 1000 10000 node lists */
  listtest2();
  mswCheckHeap(1);

  /* Check that tree is still there */
  printtree(gp);

  mswCheckHeap(1);
  mswShowInfo();

  exit(0);
}

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Contact— JavaScript license information— Web API

back to top