home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / intrvews / xgrab.lha / xgrab / ui / OGC / cons.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-03-06  |  802 b   |  36 lines

  1. /**
  2.    GRAB Graph Layout and Browser System
  3.  
  4.    Copyright (c) 1989, Tera Computer Company
  5.  **/
  6.  
  7. /* Silly implementation of Lisp cons. Intentionally wastes lots of space */
  8. /* to test collector.                                                    */
  9. # include <stdio.h>
  10. # include "cons.h"
  11.  
  12. int extra_count = 0;        /* Amount of space wasted in cons node */
  13.  
  14. sexpr cons (x, y)
  15. sexpr x;
  16. sexpr y;
  17. {
  18.     register sexpr r;
  19.     register int i;
  20.     register int *p;
  21.     
  22.     extra_count++;
  23.     extra_count %= 3000;
  24.     r = (sexpr) gc_malloc(8 + extra_count);
  25.     for (p = (int *)r; ((char *)p) < ((char *)r) + extra_count + 8; p++) {
  26.     if (*p) {
  27.         fprintf(stderr, "Found nonzero at %X\n", p);
  28.         abort(p);
  29.         }
  30.         *p = 13;
  31.     }
  32.     r -> sexpr_car = x;
  33.     r -> sexpr_cdr = y;
  34.     return(r);
  35. }
  36.