148069Sbostic /*- 2*62163Sbostic * Copyright (c) 1980, 1993 3*62163Sbostic * The Regents of the University of California. All rights reserved. 448069Sbostic * 548069Sbostic * %sccs.include.redist.c% 622563Sdist */ 75539Slinton 822563Sdist #ifndef lint 9*62163Sbostic static char sccsid[] = "@(#)tfree.c 8.1 (Berkeley) 06/06/93"; 1048069Sbostic #endif /* not lint */ 115539Slinton 125539Slinton /* 135539Slinton * Free a tree; this is expensive but useful. 145539Slinton */ 155539Slinton 165539Slinton #include "defs.h" 175539Slinton #include "tree.h" 185539Slinton #include "sym.h" 195539Slinton #include "tree.rep" 205539Slinton tfree(p)215539Slintontfree(p) 225539Slinton register NODE *p; 235539Slinton { 245539Slinton if (p == NIL) { 255539Slinton return; 265539Slinton } 275539Slinton switch(degree(p->op)) { 285539Slinton case LEAF: 295539Slinton switch(p->op) { 305539Slinton case O_CALL: 315539Slinton tfree(p->left); 325539Slinton tfree(p->right); 335539Slinton break; 345539Slinton 355539Slinton case O_QLINE: 365539Slinton dispose(p->left->sconval); 375539Slinton dispose(p->left); 385539Slinton tfree(p->right); 395539Slinton break; 405539Slinton 415539Slinton case O_ALIAS: 425539Slinton dispose(p->left->sconval); 435539Slinton dispose(p->left); 445539Slinton dispose(p->right->sconval); 455539Slinton dispose(p->right); 465539Slinton break; 475539Slinton 485539Slinton case O_SCON: 495539Slinton unmkstring(p->nodetype); 505539Slinton free(p->nodetype); 515539Slinton free(p->sconval); 525539Slinton p->sconval = NIL; 535539Slinton break; 545539Slinton } 555539Slinton break; 565539Slinton 575539Slinton case BINARY: 585539Slinton tfree(p->right); 595539Slinton /* fall through */ 605539Slinton case UNARY: 615539Slinton tfree(p->left); 625539Slinton break; 635539Slinton 645539Slinton default: 655539Slinton panic("bad op %d in tfree", p->op); 665539Slinton } 675539Slinton dispose(p); 685539Slinton } 69