mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 09:11:48 +00:00
Merge branch 'align-memory-addresses' into 'next'
Make sure all allocations are properly aligned See merge request STJr/SRB2!2050
This commit is contained in:
commit
858c9ef0b2
6 changed files with 17 additions and 21 deletions
|
@ -498,7 +498,7 @@ INT32 CL_CheckFiles(void)
|
||||||
CONS_Debug(DBG_NETPLAY, "searching for '%s' ", fileneeded[i].filename);
|
CONS_Debug(DBG_NETPLAY, "searching for '%s' ", fileneeded[i].filename);
|
||||||
|
|
||||||
// Check in already loaded files
|
// Check in already loaded files
|
||||||
for (j = mainwads; wadfiles[j]; j++)
|
for (j = mainwads; j < numwadfiles; j++)
|
||||||
{
|
{
|
||||||
nameonly(strcpy(wadfilename, wadfiles[j]->filename));
|
nameonly(strcpy(wadfilename, wadfiles[j]->filename));
|
||||||
if (!stricmp(wadfilename, fileneeded[i].filename) &&
|
if (!stricmp(wadfilename, fileneeded[i].filename) &&
|
||||||
|
|
|
@ -103,7 +103,7 @@ huddrawlist_h LUA_HUD_CreateDrawList(void)
|
||||||
{
|
{
|
||||||
huddrawlist_h drawlist;
|
huddrawlist_h drawlist;
|
||||||
|
|
||||||
drawlist = (huddrawlist_h) Z_CallocAlign(sizeof(struct huddrawlist_s), PU_STATIC, NULL, 64);
|
drawlist = (huddrawlist_h) Z_Calloc(sizeof(struct huddrawlist_s), PU_STATIC, NULL);
|
||||||
drawlist->items = NULL;
|
drawlist->items = NULL;
|
||||||
drawlist->items_capacity = 0;
|
drawlist->items_capacity = 0;
|
||||||
drawlist->items_len = 0;
|
drawlist->items_len = 0;
|
||||||
|
@ -160,7 +160,7 @@ static size_t AllocateDrawItem(huddrawlist_h list)
|
||||||
{
|
{
|
||||||
if (list->items_capacity == 0) list->items_capacity = 128;
|
if (list->items_capacity == 0) list->items_capacity = 128;
|
||||||
else list->items_capacity *= 2;
|
else list->items_capacity *= 2;
|
||||||
list->items = (drawitem_t *) Z_ReallocAlign(list->items, sizeof(struct drawitem_s) * list->items_capacity, PU_STATIC, NULL, 64);
|
list->items = (drawitem_t *) Z_Realloc(list->items, sizeof(struct drawitem_s) * list->items_capacity, PU_STATIC, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list->items_len++;
|
return list->items_len++;
|
||||||
|
@ -179,7 +179,7 @@ static const char *CopyString(huddrawlist_h list, const char* str)
|
||||||
{
|
{
|
||||||
if (list->strbuf_capacity == 0) list->strbuf_capacity = 256;
|
if (list->strbuf_capacity == 0) list->strbuf_capacity = 256;
|
||||||
else list->strbuf_capacity *= 2;
|
else list->strbuf_capacity *= 2;
|
||||||
list->strbuf = (char*) Z_ReallocAlign(list->strbuf, sizeof(char) * list->strbuf_capacity, PU_STATIC, NULL, 8);
|
list->strbuf = (char*) Z_Realloc(list->strbuf, sizeof(char) * list->strbuf_capacity, PU_STATIC, NULL);
|
||||||
}
|
}
|
||||||
const char *result = (const char *) &list->strbuf[list->strbuf_len];
|
const char *result = (const char *) &list->strbuf[list->strbuf_len];
|
||||||
strncpy(&list->strbuf[list->strbuf_len], str, lenstr + 1);
|
strncpy(&list->strbuf[list->strbuf_len], str, lenstr + 1);
|
||||||
|
|
17
src/r_fps.c
17
src/r_fps.c
|
@ -369,12 +369,11 @@ static void AddInterpolator(levelinterpolator_t* interpolator)
|
||||||
levelinterpolators_size *= 2;
|
levelinterpolators_size *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
levelinterpolators = Z_ReallocAlign(
|
levelinterpolators = Z_Realloc(
|
||||||
(void*) levelinterpolators,
|
(void*) levelinterpolators,
|
||||||
sizeof(levelinterpolator_t*) * levelinterpolators_size,
|
sizeof(levelinterpolator_t*) * levelinterpolators_size,
|
||||||
PU_LEVEL,
|
PU_LEVEL,
|
||||||
NULL,
|
NULL
|
||||||
sizeof(levelinterpolator_t*) * 8
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,11 +383,8 @@ static void AddInterpolator(levelinterpolator_t* interpolator)
|
||||||
|
|
||||||
static levelinterpolator_t *CreateInterpolator(levelinterpolator_type_e type, thinker_t *thinker)
|
static levelinterpolator_t *CreateInterpolator(levelinterpolator_type_e type, thinker_t *thinker)
|
||||||
{
|
{
|
||||||
levelinterpolator_t *ret = (levelinterpolator_t*) Z_CallocAlign(
|
levelinterpolator_t *ret = (levelinterpolator_t*) Z_Calloc(
|
||||||
sizeof(levelinterpolator_t),
|
sizeof(levelinterpolator_t), PU_LEVEL, NULL
|
||||||
PU_LEVEL,
|
|
||||||
NULL,
|
|
||||||
sizeof(levelinterpolator_t) * 8
|
|
||||||
);
|
);
|
||||||
|
|
||||||
ret->type = type;
|
ret->type = type;
|
||||||
|
@ -703,12 +699,11 @@ void R_AddMobjInterpolator(mobj_t *mobj)
|
||||||
interpolated_mobjs_capacity *= 2;
|
interpolated_mobjs_capacity *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
interpolated_mobjs = Z_ReallocAlign(
|
interpolated_mobjs = Z_Realloc(
|
||||||
interpolated_mobjs,
|
interpolated_mobjs,
|
||||||
sizeof(mobj_t *) * interpolated_mobjs_capacity,
|
sizeof(mobj_t *) * interpolated_mobjs_capacity,
|
||||||
PU_LEVEL,
|
PU_LEVEL,
|
||||||
NULL,
|
NULL
|
||||||
64
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -972,7 +972,7 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup)
|
||||||
// add the wadfile
|
// add the wadfile
|
||||||
//
|
//
|
||||||
CONS_Printf(M_GetText("Added file %s (%u lumps)\n"), filename, numlumps);
|
CONS_Printf(M_GetText("Added file %s (%u lumps)\n"), filename, numlumps);
|
||||||
wadfiles = Z_Realloc(wadfiles, sizeof(wadfile_t) * (numwadfiles + 1), PU_STATIC, NULL);
|
wadfiles = Z_Realloc(wadfiles, sizeof(wadfile_t *) * (numwadfiles + 1), PU_STATIC, NULL);
|
||||||
wadfiles[numwadfiles] = wadfile;
|
wadfiles[numwadfiles] = wadfile;
|
||||||
numwadfiles++; // must come BEFORE W_LoadDehackedLumps, so any addfile called by COM_BufInsertText called by Lua doesn't overwrite what we just loaded
|
numwadfiles++; // must come BEFORE W_LoadDehackedLumps, so any addfile called by COM_BufInsertText called by Lua doesn't overwrite what we just loaded
|
||||||
|
|
||||||
|
|
|
@ -287,7 +287,8 @@ void *Z_Malloc2(size_t size, INT32 tag, void *user, INT32 alignbits,
|
||||||
void *Z_MallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits)
|
void *Z_MallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
size_t extrabytes = (1<<alignbits) - 1;
|
I_Assert(alignbits >= 0 && alignbits < (INT32)(sizeof(size_t) * 8));
|
||||||
|
size_t extrabytes = ((size_t)1<<alignbits) - 1;
|
||||||
size_t padsize = 0;
|
size_t padsize = 0;
|
||||||
memblock_t *block;
|
memblock_t *block;
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
|
@ -101,10 +101,10 @@ void *Z_CallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits) FUNCALL
|
||||||
void *Z_ReallocAlign(void *ptr, size_t size, INT32 tag, void *user, INT32 alignbits) FUNCALLOC(2);
|
void *Z_ReallocAlign(void *ptr, size_t size, INT32 tag, void *user, INT32 alignbits) FUNCALLOC(2);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Alloc with no alignment
|
// Alloc with standard alignment
|
||||||
#define Z_Malloc(s,t,u) Z_MallocAlign(s, t, u, 0)
|
#define Z_Malloc(s,t,u) Z_MallocAlign(s, t, u, sizeof(void *))
|
||||||
#define Z_Calloc(s,t,u) Z_CallocAlign(s, t, u, 0)
|
#define Z_Calloc(s,t,u) Z_CallocAlign(s, t, u, sizeof(void *))
|
||||||
#define Z_Realloc(p,s,t,u) Z_ReallocAlign(p, s, t, u, 0)
|
#define Z_Realloc(p,s,t,u) Z_ReallocAlign(p, s, t, u, sizeof(void *))
|
||||||
|
|
||||||
// Free all memory by tag
|
// Free all memory by tag
|
||||||
// these don't give line numbers for ZDEBUG currently though
|
// these don't give line numbers for ZDEBUG currently though
|
||||||
|
|
Loading…
Reference in a new issue