dont free our poly_subsectors twice

also use calloc for em
This commit is contained in:
Alug committed 2025-07-24 14:50:12 +02:00
1 parent a8a638c5e6
commit b2d1771e79
4 files changed
+19 -20

No files matched your search

+15 -14
View File
@@ -537,6 +537,8 @@ static byte* gr_polypool = NULL;
static unsigned int gr_polypool_free = 0;
#endif
static void HWR_Free_poly_subsectors(void);
// only between levels, clear poly pool
static void HWR_Clear_Polys(void)
{
@@ -550,14 +552,14 @@ static void HWR_Clear_Polys(void)
}
// allocate pool for fast alloc of polys
void HWR_InitPolyPool(void)
void HWR_Init_PolyPool(void)
{
HWR_Clear_Polys();
}
void HWR_FreePolyPool(void)
void HWR_Free_PolyPool(void)
{
HWR_FreeExtraSubsectors();
HWR_Free_poly_subsectors();
HWR_Clear_Polys();
}
@@ -2254,7 +2256,7 @@ bad_node:
bspnum, numnodes);
}
void HWR_FreeExtraSubsectors(void)
static void HWR_Free_poly_subsectors(void)
{
if (poly_subsectors)
{
@@ -2924,6 +2926,7 @@ void HWR_CreatePlanePolygons(INT32 bspnum)
(void)bspnum;
CONS_Debug(DBG_RENDER, "Creating polygons, please wait...\n");
#ifdef HWR_LOADING_SCREEN
ls_count = ls_percent = 0; // reset the loading status
CON_Drawer(); //let the user know what we are doing
@@ -2933,7 +2936,7 @@ void HWR_CreatePlanePolygons(INT32 bspnum)
// reset the portal flag
gl_maphasportals = 0;
HWR_Clear_Polys ();
HWR_Clear_Polys();
// Enter all vertexes into the root bounding box.
// find min/max boundaries of map
@@ -2944,18 +2947,16 @@ void HWR_CreatePlanePolygons(INT32 bspnum)
//CONS_Debug(DBG_RENDER, "Generating subsector polygons... %d subsectors\n", numsubsectors);
HWR_FreeExtraSubsectors ();
HWR_Free_poly_subsectors();
// allocate extra data for each subsector present in map
num_alloc_poly_subsector = numsubsectors + NUM_EXTRA_SUBSECTORS;
poly_subsectors = Z_Malloc( sizeof(poly_subsector_t) * num_alloc_poly_subsector, PU_STATIC, NULL);
// set all data in to 0 or NULL !!!
memset(poly_subsectors, 0, sizeof(poly_subsector_t) * num_alloc_poly_subsector);
poly_subsectors = Z_Calloc(sizeof(poly_subsector_t) * num_alloc_poly_subsector, PU_STATIC, NULL); // set all data in to 0 or NULL !!!
wpoly_subsectors = Z_Malloc( sizeof(wpoly_t) * num_alloc_poly_subsector, PU_HWRPLANE, NULL);
memset(wpoly_subsectors, 0, sizeof(wpoly_t) * num_alloc_poly_subsector);
wpoly_subsectors = Z_Calloc(sizeof(wpoly_t) * num_alloc_poly_subsector, PU_HWRPLANE, NULL);
// allocate table for back to front drawing of subsectors
/*gr_drawsubsectors = (short*)malloc (sizeof(*gr_drawsubsectors) * num_alloc_poly_subsector);
/*gr_drawsubsectors = (short*)malloc(sizeof(*gr_drawsubsectors) * num_alloc_poly_subsector);
if (!gr_drawsubsectors)
I_Error("couldn't malloc gr_drawsubsectors\n");*/
@@ -2966,7 +2967,7 @@ void HWR_CreatePlanePolygons(INT32 bspnum)
num_poly_subsector = numsubsectors;
// construct the initial convex poly that encloses the full map
wpoly_init_alloc( 4, &rootp); // alloc space for 4 pts
wpoly_init_alloc(4, &rootp); // alloc space for 4 pts
#ifdef DEBUG_TRACE
rootp.id1 = poly_id++;
rootp.id2 = 0;
@@ -2991,7 +2992,7 @@ void HWR_CreatePlanePolygons(INT32 bspnum)
: (0 | NF_SUBSECTOR)), // Degenerate, sector 0
&rootp, NULL, rootbbox);
SolveTProblem ();
SolveTProblem();
AdjustSegs();
#ifdef POLYTILE
+2 -3
View File
@@ -55,9 +55,8 @@ void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32
extern poly_subsector_t *poly_subsectors;
extern size_t num_poly_subsector;
void HWR_InitPolyPool(void);
void HWR_FreePolyPool(void);
void HWR_FreeExtraSubsectors(void);
void HWR_Init_PolyPool(void);
void HWR_Free_PolyPool(void);
// --------
// hw_cache.c
+2 -2
View File
@@ -5958,7 +5958,7 @@ void HWR_Startup(void)
CONS_Printf("HWR_Startup()...\n");
textureformat = patchformat = GL_TEXFMT_RGBA;
HWR_InitPolyPool();
HWR_Init_PolyPool();
HWR_InitMapTextures();
HWR_InitMD2();
@@ -6051,7 +6051,7 @@ static void COM_HWR_glinfo(void)
void HWR_Shutdown(void)
{
CONS_Printf("HWR_Shutdown()\n");
HWR_FreePolyPool();
HWR_Free_PolyPool();
HWR_FreeMapTextures();
GL_FlushScreenTextures();
#ifdef USE_FBO_OGL
-1
View File
@@ -3006,7 +3006,6 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate)
#ifdef HWRENDER // not win32 only 19990829 by Kin
if (rendermode == render_opengl)
{
HWR_FreeExtraSubsectors();
// Create plane polygons.
HWR_LoadLevel(reloadinggamestate);
}