sym.c 966 B

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