diff -ur abuse_sdl-0.7.0.orig/src/include/stack.hpp abuse_sdl-0.7.0/src/include/stack.hpp
--- abuse_sdl-0.7.0.orig/src/include/stack.hpp 2002-12-15 06:00:32.000000000 +0100
+++ abuse_sdl-0.7.0/src/include/stack.hpp 2006-08-16 16:54:58.000000000 +0200
@@ -13,20 +13,38 @@
{
public :
T **sdata;
- long son;
-
- grow_stack(int max_size) { sdata=(T **)jmalloc(max_size,"pointer stack"); son=0; }
+ unsigned int son, _max_size;
+ /* <sigh> the max_size parameter is the number of bytes of the pointerstack
+ instead of the number of entries which it ofcourse should have been.
+ This breaks on 64 bit since the caller assumes 4 bytes per pointer and
+ thus on 64 bit allocates not enough memory. Instead of fixing all callers
+ we work around this by multiplying maxsize by 2 on 64 bit. */
+ grow_stack(unsigned int max_size)
+ {
+ max_size *= sizeof(void*)/sizeof(int);
+ sdata = (T **)jmalloc(max_size, "pointer stack");
+ son=0;
+ _max_size=max_size;
+ }
+
void push(T *data)
{
sdata[son]=data;
son++;
+ if (son >= (_max_size/sizeof(int)))
+ {
+ lbreak("stack overflow\n");
+ exit(0);
+ }
}
- T *pop(long total)
- { if (total>son) { lbreak("stack underflow\n"); exit(0); }
+ T *pop(unsigned int total)
+ {
+ if (total>son) { lbreak("stack underflow\n"); exit(0); }
son-=total;
return sdata[son];
}
+
void clean_up()
{
if (son!=0) fprintf(stderr,"Warning cleaning up stack and not empty\n");
diff -ur abuse_sdl-0.7.0.orig/src/light.cpp abuse_sdl-0.7.0/src/light.cpp
--- abuse_sdl-0.7.0.orig/src/light.cpp 2006-08-16 16:56:33.000000000 +0200
+++ abuse_sdl-0.7.0/src/light.cpp 2006-08-16 16:36:07.000000000 +0200
@@ -348,7 +348,7 @@
// f->write(green_light,256*64);
for (int i=0;i<TTINTS;i++)
f->write(tints[i],256);
- fp->write(bright_tint,256);
+ f->write(bright_tint,256);
// f.write(trans_table,256*256);
}
delete f;