From 205b8a76776933161e079e3f170baddefd31776d Mon Sep 17 00:00:00 2001 From: helixhorned Date: Fri, 7 Nov 2014 22:07:12 +0000 Subject: [PATCH] C-CON: fix 'readgamearray' and 'resizearray' on Windows. We must not use Xrealloc(), since gamearrays are now allocated with Xaligned_alloc(). NOTE: I did not check all potential problematic cases, only those to get LNGA3 up and running. git-svn-id: https://svn.eduke32.com/eduke32@4735 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/gameexec.c | 8 +++++--- polymer/eduke32/source/gamevars.c | 3 --- polymer/eduke32/source/gamevars.h | 4 ++++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index d0d634b44..75cabaf84 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -4461,8 +4461,9 @@ finish_qsprintf: int32_t *tmpar = Xmalloc(numbytes); kread(fil, tmpar, numbytes); #endif - aGameArrays[j].plValues = (intptr_t *)Xrealloc( - aGameArrays[j].plValues, numelts * GAR_ELTSZ); + Baligned_free(aGameArrays[j].plValues); + aGameArrays[j].plValues = (intptr_t *)Xaligned_alloc( + ACTOR_VAR_ALIGNMENT, numelts * GAR_ELTSZ); aGameArrays[j].size = numelts; #ifdef BITNESS64 for (int32_t i=0; i 0) { /*OSD_Printf(OSDTEXT_GREEN "CON_RESIZEARRAY: resizing array %s from %d to %d\n", aGameArrays[j].szLabel, aGameArrays[j].size, asize);*/ - aGameArrays[j].plValues = (intptr_t *)Xrealloc(aGameArrays[j].plValues, GAR_ELTSZ * asize); + Baligned_free(aGameArrays[j].plValues); + aGameArrays[j].plValues = (intptr_t *)Xaligned_alloc(ACTOR_VAR_ALIGNMENT, GAR_ELTSZ * asize); aGameArrays[j].size = asize; } continue; diff --git a/polymer/eduke32/source/gamevars.c b/polymer/eduke32/source/gamevars.c index afcbd124e..14543b3fd 100644 --- a/polymer/eduke32/source/gamevars.c +++ b/polymer/eduke32/source/gamevars.c @@ -30,9 +30,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define _gamevars_c_ -#define PLAYER_VAR_ALIGNMENT (sizeof(intptr_t)) -#define ACTOR_VAR_ALIGNMENT 16 - #ifdef LUNATIC int32_t g_noResetVars; LUNATIC_CB void (*A_ResetVars)(int32_t iActor); diff --git a/polymer/eduke32/source/gamevars.h b/polymer/eduke32/source/gamevars.h index 7e31f27f7..ac8d7dd0a 100644 --- a/polymer/eduke32/source/gamevars.h +++ b/polymer/eduke32/source/gamevars.h @@ -50,6 +50,10 @@ enum GamevarFlags_t { #if !defined LUNATIC +// Alignments for per-player and per-across variables. +#define PLAYER_VAR_ALIGNMENT (sizeof(intptr_t)) +#define ACTOR_VAR_ALIGNMENT 16 + # define MAXGAMEARRAYS (MAXGAMEVARS>>2) // must be lower than MAXGAMEVARS # define MAXARRAYLABEL MAXVARLABEL