4945: Format global static variable name in macro r=def- a=Chairn

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Chairn <chairn.nq@hotmail.fr>
This commit is contained in:
bors[bot] 2022-04-03 08:17:54 +00:00 committed by GitHub
commit 7666735fe3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -56,36 +56,36 @@ private:
#endif
#define MACRO_ALLOC_POOL_ID_IMPL(POOLTYPE, PoolSize) \
static char ms_PoolData##POOLTYPE[PoolSize][MACRO_ALLOC_GET_SIZE(POOLTYPE)] = {{0}}; \
static int ms_PoolUsed##POOLTYPE[PoolSize] = {0}; \
MAYBE_UNUSED static int ms_PoolDummy##POOLTYPE = (ASAN_POISON_MEMORY_REGION(ms_PoolData##POOLTYPE, sizeof(ms_PoolData##POOLTYPE)), 0); \
static char gs_PoolData##POOLTYPE[PoolSize][MACRO_ALLOC_GET_SIZE(POOLTYPE)] = {{0}}; \
static int gs_PoolUsed##POOLTYPE[PoolSize] = {0}; \
MAYBE_UNUSED static int gs_PoolDummy##POOLTYPE = (ASAN_POISON_MEMORY_REGION(gs_PoolData##POOLTYPE, sizeof(gs_PoolData##POOLTYPE)), 0); \
void *POOLTYPE::operator new(size_t Size, int id) \
{ \
dbg_assert(sizeof(POOLTYPE) >= Size, "size error"); \
dbg_assert(!ms_PoolUsed##POOLTYPE[id], "already used"); \
dbg_assert(!gs_PoolUsed##POOLTYPE[id], "already used"); \
/*dbg_msg("pool", "++ %s %d", #POOLTYPE, id);*/ \
ASAN_UNPOISON_MEMORY_REGION(ms_PoolData##POOLTYPE[id], sizeof(ms_PoolData##POOLTYPE[id])); \
ms_PoolUsed##POOLTYPE[id] = 1; \
mem_zero(ms_PoolData##POOLTYPE[id], sizeof(ms_PoolData##POOLTYPE[id])); \
return ms_PoolData##POOLTYPE[id]; \
ASAN_UNPOISON_MEMORY_REGION(gs_PoolData##POOLTYPE[id], sizeof(gs_PoolData##POOLTYPE[id])); \
gs_PoolUsed##POOLTYPE[id] = 1; \
mem_zero(gs_PoolData##POOLTYPE[id], sizeof(gs_PoolData##POOLTYPE[id])); \
return gs_PoolData##POOLTYPE[id]; \
} \
void POOLTYPE::operator delete(void *p, int id) \
{ \
dbg_assert(ms_PoolUsed##POOLTYPE[id], "not used"); \
dbg_assert(id == (POOLTYPE *)p - (POOLTYPE *)ms_PoolData##POOLTYPE, "invalid id"); \
dbg_assert(gs_PoolUsed##POOLTYPE[id], "not used"); \
dbg_assert(id == (POOLTYPE *)p - (POOLTYPE *)gs_PoolData##POOLTYPE, "invalid id"); \
/*dbg_msg("pool", "-- %s %d", #POOLTYPE, id);*/ \
ms_PoolUsed##POOLTYPE[id] = 0; \
mem_zero(ms_PoolData##POOLTYPE[id], sizeof(ms_PoolData##POOLTYPE[id])); \
ASAN_POISON_MEMORY_REGION(ms_PoolData##POOLTYPE[id], sizeof(ms_PoolData##POOLTYPE[id])); \
gs_PoolUsed##POOLTYPE[id] = 0; \
mem_zero(gs_PoolData##POOLTYPE[id], sizeof(gs_PoolData##POOLTYPE[id])); \
ASAN_POISON_MEMORY_REGION(gs_PoolData##POOLTYPE[id], sizeof(gs_PoolData##POOLTYPE[id])); \
} \
void POOLTYPE::operator delete(void *p) /* NOLINT(misc-new-delete-overloads) */ \
{ \
int id = (POOLTYPE *)p - (POOLTYPE *)ms_PoolData##POOLTYPE; \
dbg_assert(ms_PoolUsed##POOLTYPE[id], "not used"); \
int id = (POOLTYPE *)p - (POOLTYPE *)gs_PoolData##POOLTYPE; \
dbg_assert(gs_PoolUsed##POOLTYPE[id], "not used"); \
/*dbg_msg("pool", "-- %s %d", #POOLTYPE, id);*/ \
ms_PoolUsed##POOLTYPE[id] = 0; \
mem_zero(ms_PoolData##POOLTYPE[id], sizeof(ms_PoolData##POOLTYPE[id])); \
ASAN_POISON_MEMORY_REGION(ms_PoolData##POOLTYPE[id], sizeof(ms_PoolData##POOLTYPE[id])); \
gs_PoolUsed##POOLTYPE[id] = 0; \
mem_zero(gs_PoolData##POOLTYPE[id], sizeof(gs_PoolData##POOLTYPE[id])); \
ASAN_POISON_MEMORY_REGION(gs_PoolData##POOLTYPE[id], sizeof(gs_PoolData##POOLTYPE[id])); \
}
#endif