1 /* This file is part of the GNU plotutils package. */
2 
3 /*
4  * Copyright (C) 1982-1994, Nicholas B. Tufillaro.  All rights reserved.
5  *
6  * GNU enhancements Copyright (C) 1996, 1997, 1998, 1999, 2005, 2008, Free
7  * Software Foundation, Inc.
8  */
9 
10 /*
11  * symbol table space management routines
12  *
13  */
14 
15 #include "sys-defines.h"
16 #include "ode.h"
17 #include "extern.h"
18 
19 struct sym *
lookup(const char * nam)20 lookup (const char *nam)
21 {
22   struct sym *sp;
23 
24   for (sp = symtab; sp != NULL; sp = sp->sy_link)
25     if (strncmp (sp->sy_name, nam, NAMMAX) == 0)
26       return sp;
27   sp = salloc();
28   strncpy (sp->sy_name, nam, NAMMAX);
29   return sp;
30 }
31 
32 struct sym *
salloc(void)33 salloc (void)
34 {
35   struct sym *sp;
36 
37   sp = (struct sym *)xmalloc(sizeof(struct sym));
38   sp->sy_link = symtab;
39   symtab = sp;
40   sp->sy_expr = NULL;
41   sp->sy_value = sp->sy_prime = 0.0;
42   sp->sy_sserr = sp->sy_aberr = sp->sy_acerr = 0.0;
43   sp->sy_flags = 0;
44   return sp;
45 }
46 
47 void
sfree(struct sym * sp)48 sfree (struct sym *sp)
49 {
50   if (sp != NULL)
51     free ((void *)sp);
52 }
53