mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-15 00:31:54 +00:00
Use flexible array members for structs that end with var-sized arrays
- Since Clang++, G++, and VC++ all support this extension (even though it's technically officially only part of C99), use it. It lets Clang's array- bounds checker know that these are meant to be accessed out of their so-called "bounds".
This commit is contained in:
parent
fbddfbe576
commit
43fe317dbe
4 changed files with 7 additions and 7 deletions
|
@ -558,8 +558,8 @@ static visplane_t *new_visplane (unsigned hash)
|
|||
|
||||
if (check == NULL)
|
||||
{
|
||||
check = (visplane_t *)M_Malloc (sizeof(*check) + sizeof(*check->top)*(MAXWIDTH*2));
|
||||
memset(check, 0, sizeof(*check) + sizeof(*check->top)*(MAXWIDTH*2));
|
||||
check = (visplane_t *)M_Malloc (sizeof(*check) + 3 + sizeof(*check->top)*(MAXWIDTH*2));
|
||||
memset(check, 0, sizeof(*check) + 3 + sizeof(*check->top)*(MAXWIDTH*2));
|
||||
check->bottom = check->top + MAXWIDTH+2;
|
||||
}
|
||||
else if (NULL == (freetail = freetail->next))
|
||||
|
|
|
@ -63,7 +63,7 @@ struct visplane_s
|
|||
|
||||
unsigned short *bottom; // [RH] bottom and top arrays are dynamically
|
||||
unsigned short pad; // allocated immediately after the
|
||||
unsigned short top[3]; // visplane.
|
||||
unsigned short top[]; // visplane.
|
||||
};
|
||||
typedef struct visplane_s visplane_t;
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ struct FStringTable::StringEntry
|
|||
StringEntry *Next;
|
||||
char *Name;
|
||||
BYTE PassNum;
|
||||
char String[2];
|
||||
char String[];
|
||||
};
|
||||
|
||||
FStringTable::FStringTable ()
|
||||
|
@ -283,7 +283,7 @@ void FStringTable::LoadLanguage (int lumpnum, DWORD code, bool exactMatch, int p
|
|||
}
|
||||
if (entry == NULL || cmpval > 0)
|
||||
{
|
||||
entry = (StringEntry *)M_Malloc (sizeof(*entry) + strText.Len() + strName.Len());
|
||||
entry = (StringEntry *)M_Malloc (sizeof(*entry) + strText.Len() + strName.Len() + 2);
|
||||
entry->Next = *pentry;
|
||||
*pentry = entry;
|
||||
strcpy (entry->String, strText.GetChars());
|
||||
|
@ -409,7 +409,7 @@ void FStringTable::SetString (const char *name, const char *newString)
|
|||
size_t namelen = strlen (name);
|
||||
|
||||
// Create a new string entry
|
||||
StringEntry *entry = (StringEntry *)M_Malloc (sizeof(*entry) + newlen + namelen);
|
||||
StringEntry *entry = (StringEntry *)M_Malloc (sizeof(*entry) + newlen + namelen + 2);
|
||||
strcpy (entry->String, newString);
|
||||
strcpy (entry->Name = entry->String + newlen + 1, name);
|
||||
entry->PassNum = 0;
|
||||
|
|
|
@ -119,7 +119,7 @@ struct patch_t
|
|||
SWORD height;
|
||||
SWORD leftoffset; // pixels to the left of origin
|
||||
SWORD topoffset; // pixels below the origin
|
||||
DWORD columnofs[8]; // only [width] used
|
||||
DWORD columnofs[]; // only [width] used
|
||||
// the [0] is &columnofs[width]
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue