mirror of
https://github.com/libretro/libretro-tyrquake.git
synced 2024-12-12 02:34:13 +00:00
model: use zero sized arrays for variable sized sprite structs
Also fixes an incorrect use of sizeof which was previously papered over by the padded size of the struct. Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
parent
dc561715a1
commit
abfcd14de1
@ -91,9 +91,8 @@ Mod_LoadSpriteGroup(void *pin, mspriteframe_t **ppframe, const char *loadname,
|
||||
pingroup = (dspritegroup_t *)pin;
|
||||
numframes = LittleLong(pingroup->numframes);
|
||||
|
||||
pspritegroup = Hunk_AllocName(sizeof(mspritegroup_t) +
|
||||
(numframes -
|
||||
1) * sizeof(pspritegroup->frames[0]),
|
||||
pspritegroup = Hunk_AllocName(sizeof(*pspritegroup) +
|
||||
numframes * sizeof(pspritegroup->frames[0]),
|
||||
loadname);
|
||||
|
||||
pspritegroup->numframes = numframes;
|
||||
@ -138,7 +137,7 @@ Mod_LoadSpriteModel(model_t *mod, void *buffer, const char *loadname)
|
||||
int size;
|
||||
dspriteframetype_t *pframetype;
|
||||
|
||||
pin = (dsprite_t *) buffer;
|
||||
pin = (dsprite_t *)buffer;
|
||||
|
||||
version = LittleLong(pin->version);
|
||||
if (version != SPRITE_VERSION)
|
||||
@ -146,7 +145,7 @@ Mod_LoadSpriteModel(model_t *mod, void *buffer, const char *loadname)
|
||||
__func__, mod->name, version, SPRITE_VERSION);
|
||||
|
||||
numframes = LittleLong(pin->numframes);
|
||||
size = sizeof(msprite_t) + (numframes - 1) * sizeof(psprite->frames);
|
||||
size = sizeof(*psprite) + numframes * sizeof(psprite->frames[0]);
|
||||
psprite = Hunk_AllocName(size, loadname);
|
||||
mod->cache.data = psprite;
|
||||
|
||||
|
@ -240,7 +240,7 @@ void R_SpriteDataStore(mspriteframe_t *frame, const char *modelname,
|
||||
typedef struct {
|
||||
int numframes;
|
||||
float *intervals;
|
||||
mspriteframe_t *frames[1];
|
||||
mspriteframe_t *frames[0]; /* variable sized */
|
||||
} mspritegroup_t;
|
||||
|
||||
typedef struct {
|
||||
@ -255,7 +255,7 @@ typedef struct {
|
||||
int numframes;
|
||||
float beamlength; // remove?
|
||||
void *cachespot; // remove?
|
||||
mspriteframedesc_t frames[1];
|
||||
mspriteframedesc_t frames[0]; /* variable sized */
|
||||
} msprite_t;
|
||||
|
||||
#ifdef QW_HACK
|
||||
|
@ -220,7 +220,7 @@ void R_SpriteDataStore(mspriteframe_t *frame, const char *modelname,
|
||||
typedef struct {
|
||||
int numframes;
|
||||
float *intervals;
|
||||
mspriteframe_t *frames[1];
|
||||
mspriteframe_t *frames[0]; /* variable sized */
|
||||
} mspritegroup_t;
|
||||
|
||||
typedef struct {
|
||||
@ -235,7 +235,7 @@ typedef struct {
|
||||
int numframes;
|
||||
float beamlength; // remove?
|
||||
void *cachespot; // remove?
|
||||
mspriteframedesc_t frames[1];
|
||||
mspriteframedesc_t frames[0]; /* variable sized */
|
||||
} msprite_t;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user