Changeset 74
- Timestamp:
- Mar 4, 2008, 6:08:07 PM (15 years ago)
- Location:
- abuse/trunk
- Files:
-
- 3 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/osx/abuse_sdl.pbproj/project.pbxproj
r73 r74 2737 2737 F5C58193028E0D6D012A168D = { 2738 2738 isa = PBXFileReference; 2739 path = stack.hpp;2739 path = lisp/stack.hpp; 2740 2740 refType = 4; 2741 2741 }; -
abuse/trunk/src/Makefile.am
r66 r74 59 59 gamma.cpp gamma.hpp \ 60 60 language.cpp language.hpp \ 61 bus_type.hpp stack.hppid.hpp netface.hpp isllist.hpp sbar.hpp \61 bus_type.hpp id.hpp netface.hpp isllist.hpp sbar.hpp \ 62 62 nfserver.hpp exitproc.hpp \ 63 63 $(NULL) -
abuse/trunk/src/lisp/Makefile.am
r62 r74 6 6 lisp_opt.cpp lisp_opt.hpp \ 7 7 lisp_gc.cpp lisp_gc.hpp \ 8 stack.hpp \ 8 9 $(NULL) 9 10 -
abuse/trunk/src/lisp/stack.hpp
r73 r74 1 1 /* 2 * Abuse - dark 2D side-scrolling platform game3 * Copyright (c) 1995 Crack dot Com2 * Abuse - dark 2D side-scrolling platform game 3 * Copyright (c) 1995 Crack dot Com 4 4 * 5 * This software was released into the Public Domain. As with most public6 * domain software, no warranty is made or implied by Crack dot Com or7 * Jonathan Clark.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 8 */ 9 9 10 10 #ifndef __STACK_HPP_ 11 11 #define __STACK_HPP_ 12 13 #include <stdio.h> 14 12 15 #ifndef NO_LIBS 13 # include "jmalloc.hpp"16 # include "jmalloc.hpp" 14 17 #else 15 # include "fakelib.hpp"18 # include "fakelib.hpp" 16 19 #endif 17 20 18 #include <stdio.h> 19 struct cons_cell; 21 // A fixed-size stack class 22 template<class T> class grow_stack 23 { 24 public: 25 T **sdata; 26 long son; 20 27 21 template<class T> class grow_stack // stack does not shrink 22 { 23 public : 24 T **sdata; 25 long son; 26 long smax; 28 private: 29 long smax; 27 30 28 grow_stack(int max_size) { 29 smax=max_size; 30 son=0; 31 sdata=(T **)jmalloc(sizeof(T *)*smax,"pointer stack"); 32 } 33 void push(T *data) 34 { 35 if (son>=smax) { lbreak("stack overflow (%ld)\n",smax); exit(1); } 36 sdata[son]=data; 37 son++; 38 } 39 40 T *pop(long total) 41 { if (total>son) { lbreak("stack underflow\n"); exit(1); } 42 son-=total; 43 return sdata[son]; 44 } 45 void clean_up() 46 { 47 if (son!=0) fprintf(stderr,"Warning cleaning up stack and not empty\n"); 48 jfree(sdata); 49 sdata=NULL; son=0; 50 } 51 } ; 31 public: 32 grow_stack(int max_size) 33 { 34 smax = max_size; 35 son = 0; 36 sdata = (T **)jmalloc(sizeof(T *) * smax, "pointer stack"); 37 } 38 39 void push(T *data) 40 { 41 if(son >= smax) 42 { 43 lbreak("error: stack overflow (%ld >= %ld)\n", son, smax); 44 exit(1); 45 } 46 sdata[son] = data; 47 son++; 48 } 49 50 T *pop(long total) 51 { 52 if (total > son) 53 { 54 lbreak("error: stack underflow\n"); 55 exit(1); 56 } 57 son -= total; 58 return sdata[son]; 59 } 60 61 void clean_up() 62 { 63 if(son != 0) 64 fprintf(stderr, "warning: cleaning up stack and not empty\n"); 65 jfree(sdata); 66 sdata = NULL; 67 son = 0; 68 } 69 }; 52 70 53 71 #endif
Note: See TracChangeset
for help on using the changeset viewer.