diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index 728681299..ae91df311 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -757,7 +757,6 @@ EXTERN int32_t yxaspect, viewingrange; extern "C" { #endif EXTERN intptr_t *ylookup; -EXTERN int32_t ylookupsiz; #ifdef __cplusplus }; #endif diff --git a/polymer/eduke32/build/src/baselayer.c b/polymer/eduke32/build/src/baselayer.c index a12e43f03..349b60177 100644 --- a/polymer/eduke32/build/src/baselayer.c +++ b/polymer/eduke32/build/src/baselayer.c @@ -187,15 +187,15 @@ int32_t nx_unprotect(intptr_t beg, intptr_t end) void calc_ylookup(int32_t bpl, int32_t lastyidx) { int32_t i, j=0; - - lastyidx++; + static int32_t ylookupsiz; Bassert(lastyidx <= MAXYDIM); + lastyidx++; + if (lastyidx > ylookupsiz) { - if (ylookup) - Baligned_free(ylookup); + Baligned_free(ylookup); ylookup = (intptr_t *)Xaligned_alloc(16, lastyidx * sizeof(intptr_t)); #if !defined(NOASM) && !defined(GEKKO) && !defined(__ANDROID__) @@ -213,7 +213,7 @@ void calc_ylookup(int32_t bpl, int32_t lastyidx) j += (bpl << 2); } - for (; i<=lastyidx; i++) + for (; i