r_brush.c (AllocBlock): use calloc() to not leave uninitialized memory.

keeps valgrind happy.
This commit is contained in:
Ozkan Sezer 2021-08-27 17:03:00 +03:00
parent 9f8b569f9b
commit 8797c8c384
1 changed files with 1 additions and 3 deletions

View File

@ -726,9 +726,7 @@ int AllocBlock (int w, int h, int *x, int *y)
lightmap_count++;
lightmaps = (struct lightmap_s *) realloc(lightmaps, sizeof(*lightmaps)*lightmap_count);
memset(&lightmaps[texnum], 0, sizeof(lightmaps[texnum]));
/* FIXME: we leave 'gaps' in malloc()ed data, CRC_Block() later accesses
* that uninitialized data and valgrind complains for it. use calloc() ? */
lightmaps[texnum].data = (byte *) malloc(4*LMBLOCK_WIDTH*LMBLOCK_HEIGHT);
lightmaps[texnum].data = (byte *) calloc(1, 4*LMBLOCK_WIDTH*LMBLOCK_HEIGHT);
//as we're only tracking one texture, we don't need multiple copies of allocated any more.
memset(allocated, 0, sizeof(allocated));
}