Move openings to r_memory
This commit is contained in:
parent
74e1955afa
commit
60c0dcc3c7
10 changed files with 67 additions and 38 deletions
52
src/swrenderer/r_memory.cpp
Normal file
52
src/swrenderer/r_memory.cpp
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include "templates.h"
|
||||
#include "doomdef.h"
|
||||
#include "m_bbox.h"
|
||||
#include "i_system.h"
|
||||
#include "p_lnspec.h"
|
||||
#include "p_setup.h"
|
||||
#include "swrenderer/r_main.h"
|
||||
#include "swrenderer/drawers/r_draw.h"
|
||||
#include "a_sharedglobal.h"
|
||||
#include "g_level.h"
|
||||
#include "p_effect.h"
|
||||
#include "doomstat.h"
|
||||
#include "r_state.h"
|
||||
#include "v_palette.h"
|
||||
#include "r_sky.h"
|
||||
#include "po_man.h"
|
||||
#include "r_data/colormaps.h"
|
||||
#include "r_memory.h"
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
short *openings;
|
||||
|
||||
namespace
|
||||
{
|
||||
size_t maxopenings;
|
||||
ptrdiff_t lastopening;
|
||||
}
|
||||
|
||||
ptrdiff_t R_NewOpening(ptrdiff_t len)
|
||||
{
|
||||
ptrdiff_t res = lastopening;
|
||||
len = (len + 1) & ~1; // only return DWORD aligned addresses because some code stores fixed_t's and floats in openings...
|
||||
lastopening += len;
|
||||
if ((size_t)lastopening > maxopenings)
|
||||
{
|
||||
do
|
||||
maxopenings = maxopenings ? maxopenings * 2 : 16384;
|
||||
while ((size_t)lastopening > maxopenings);
|
||||
openings = (short *)M_Realloc(openings, maxopenings * sizeof(*openings));
|
||||
DPrintf(DMSG_NOTIFY, "MaxOpenings increased to %zu\n", maxopenings);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void R_FreeOpenings()
|
||||
{
|
||||
lastopening = 0;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue