C:/Users/Dennis/src/lang/russell.orig/src/datatypes/consnodes.c

Go to the documentation of this file.
00001 /* 
00002  * These are some C routines to manipulate LISP style lists.
00003  */
00004 
00005 # include "parm.h"
00006 # include "consnodes.h"
00007 
00008 /*
00009  * The BAD flag traces allocs and frees.
00010  */
00011 # ifdef BAD
00012         extern boolean BADflag;
00013 # endif
00014 
00015 
00016 ConsNode * cn_cons(hd,tl)
00017 ANYTHING * hd;
00018 ConsNode * tl;
00019 {       register ConsNode *p;
00020 
00021 #       ifdef BAD
00022                 if (BADflag)
00023                         flcheck (0,0);  /* Do a complete free list check */
00024                                                         /* for the salloc free list      */
00025                 else
00026                         flcheck (0,1);  /* Do a quick free list check */
00027 #       endif
00028 
00029         p = (ConsNode *)malloc(sizeof (ConsNode) );
00030         cn_sethead( p, hd );
00031         cn_settail( p, tl );
00032 #       ifdef BAD
00033                 if (BADflag) {
00034                         diagmsg("cn_cons: addr of new node=0%o, kind=ConsNode, retaddr=0%o\n",
00035                                         p, retaddr());
00036                 }
00037 #       endif
00038         return(p);
00039 }
00040 
00041 ConsNode * cn_del_hd(l)
00042                 /* return the tail of l after freeing the first cons node */
00043                           /* of l */
00044 ConsNode *l;
00045 {       register ConsNode *p;
00046 #       ifdef BAD
00047                 if (BADflag) {
00048                         diagmsg("cn_del_hd: addr of freed node=0%o, kind=ConsNode, retaddr=0%o\n",
00049                                         l, retaddr() );
00050                 }
00051 #       endif
00052 
00053 #       ifdef BAD
00054                 if (BADflag)
00055                         flcheck (0,0);  /* Do a complete free list check */
00056                 else
00057                         flcheck (0,1);  /* Do a quick free list check */
00058 #       endif
00059 
00060         p = cn_tail(l);
00061         free(l);
00062         return(p);
00063 }
00064 
00065 
00066 

Generated on Fri Jan 25 10:39:45 2008 for russell by  doxygen 1.5.4