source: abuse/trunk/src/ltree.cpp @ 129

Last change on this file since 129 was 129, checked in by Sam Hocevar, 10 years ago
  • Get rid of jmalloc and replace it with standard malloc. Modern operating systems certainly perform a lot better than this custom implementation, and we have superior tools (eg. valgrind) to debug and profile memory usage without interfering with the code itself.
File size: 1.1 KB
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *
5 *  This software was released into the Public Domain. As with most public
6 *  domain software, no warranty is made or implied by Crack dot Com or
7 *  Jonathan Clark.
8 */
9
10#include "config.h"
11
12lisp_symbol *find_symbol(char *name)
13{
14  lisp_symbol *p=lsym_root;
15  while (p)
16  {
17    int cmp=strcmp(name,((char *)((lisp_symbol *)cs->car)->name)+sizeof(lisp_string));
18    if (cmp==0) return p;
19    else if (cmp<0) p=p->left;
20    else p=p->right;
21  }
22  return NULL;
23}
24
25
26
27lisp_symbol *make_find_symbol(char *name)
28{
29  lisp_symbol *p=lsym_root;
30  lisp_symbol **parent=&lsym_root;
31  while (p)
32  {
33    int cmp=strcmp(name,((char *)((lisp_symbol *)cs->car)->name)+sizeof(lisp_string));
34    if (cmp==0) return p;
35    else if (cmp<0)
36    {
37      parent=&p->left;
38      p=p->left;
39    }
40    else
41    {
42      parent=&p->right;
43      p=p->right;
44    }
45  }
46
47  p=malloc(sizeof(lisp_symbol));
48  p->type=L_SYMBOL;
49  p->name=new_lisp_string(name);
50  p->value=l_undefined;
51  p->function=l_undefined;
52  p->call_counter=0;
53  p->left=p->right=NULL;
54  *parent=p;
55  return p;
56}
57
58
Note: See TracBrowser for help on using the repository browser.