return;
}
- lightBytes = safe_malloc_info( numLightBytes, "SetLightBytes" );
-
- memset( lightBytes, 0, numLightBytes );
+ lightBytes = safe_malloc0_info( numLightBytes, "SetLightBytes" );
}
void SetGridPoints( int n ){
return;
}
- gridData = safe_malloc_info( numGridPoints * 8, "SetGridPoints" );
-
- memset( gridData, 0, numGridPoints * 8 );
+ gridData = safe_malloc0_info( numGridPoints * 8, "SetGridPoints" );
}
void IncDrawVerts(){
numDrawVerts = n;
numDrawVertsBuffer = numDrawVerts;
- drawVerts = safe_malloc_info( sizeof( drawVert_t ) * numDrawVertsBuffer, "IncDrawVerts" );
-
- memset( drawVerts, 0, n * sizeof( drawVert_t ) );
+ drawVerts = safe_malloc0_info( sizeof( drawVert_t ) * numDrawVertsBuffer, "IncDrawVerts" );
}
void SetDrawSurfacesBuffer(){
numDrawSurfacesBuffer = MAX_MAP_DRAW_SURFS;
- drawSurfaces = safe_malloc_info( sizeof( dsurface_t ) * numDrawSurfacesBuffer, "IncDrawSurfaces" );
-
- memset( drawSurfaces, 0, MAX_MAP_DRAW_SURFS * sizeof( drawVert_t ) );
+ drawSurfaces = safe_malloc0_info( sizeof( dsurface_t ) * numDrawSurfacesBuffer, "IncDrawSurfaces" );
}
void SetDrawSurfaces( int n ){
numDrawSurfaces = n;
numDrawSurfacesBuffer = numDrawSurfaces;
- drawSurfaces = safe_malloc_info( sizeof( dsurface_t ) * numDrawSurfacesBuffer, "IncDrawSurfaces" );
-
- memset( drawSurfaces, 0, n * sizeof( drawVert_t ) );
+ drawSurfaces = safe_malloc0_info( sizeof( dsurface_t ) * numDrawSurfacesBuffer, "IncDrawSurfaces" );
}
void BspFilesCleanup(){
epair_t *ParseEpair( void ) {
epair_t *e;
- e = safe_malloc( sizeof( epair_t ) );
- memset( e, 0, sizeof( epair_t ) );
+ e = safe_malloc0( sizeof( epair_t ) );
if ( strlen( token ) >= MAX_KEY - 1 ) {
Error( "ParseEpar: token too long" );
if ( nBlock > 0 ) {
nAllocSize += MEM_BLOCKSIZE - nBlock;
}
- buffer = safe_malloc( nAllocSize + 1 );
- memset( buffer, 0, nAllocSize + 1 );
+ buffer = safe_malloc0( nAllocSize + 1 );
SafeRead( f, buffer, length );
fclose( f );
break;
case CMAPID:
- cmapbuffer = safe_malloc( 768 );
- memset( cmapbuffer, 0, 768 );
+ cmapbuffer = safe_malloc0( 768 );
memcpy( cmapbuffer, LBM_P, chunklength );
break;
pcx_t *pcx;
byte *pack;
- pcx = safe_malloc( width * height * 2 + 1000 );
- memset( pcx, 0, sizeof( *pcx ) );
+ pcx = safe_malloc0( width * height * 2 + 1000 );
pcx->manufacturer = 0x0a; // PCX id
pcx->version = 5; // 256 color
FILE *f;
buffer = safe_malloc( width * height * 4 + 18 );
+ /* we may also use safe_malloc0 on the whole instead,
+ * this would just be a bit slower */
memset( buffer, 0, 18 );
buffer[2] = 2; // uncompressed type
buffer[12] = width & 255;
}
}
s = sizeof( *w ) + ( points ? sizeof( w->p[0] ) * ( points - 1 ) : 0 );
- w = safe_malloc( s );
- memset( w, 0, s );
+ w = safe_malloc0( s );
return w;
}
}
}
s = sizeof( *w ) + ( points ? sizeof( w->p[0] ) * ( points - 1 ) : 0 );
- w = safe_malloc( s );
- memset( w, 0, s );
+ w = safe_malloc0( s );
return w;
}
Error( "AllocBrush called with numsides = %d", numSides );
}
c = (size_t)&( ( (brush_t*) 0 )->sides[ numSides ] );
- bb = safe_malloc( c );
- memset( bb, 0, c );
+ bb = safe_malloc0( c );
if ( numthreads == 1 ) {
numActiveBrushes++;
}
tree_t *AllocTree( void ){
tree_t *tree;
- tree = safe_malloc( sizeof( *tree ) );
- memset( tree, 0, sizeof( *tree ) );
+ tree = safe_malloc0( sizeof( *tree ) );
ClearBounds( tree->mins, tree->maxs );
return tree;
node_t *AllocNode( void ){
node_t *node;
- node = safe_malloc( sizeof( *node ) );
- memset( node, 0, sizeof( *node ) );
+ node = safe_malloc0( sizeof( *node ) );
return node;
}
Sys_Printf( "--- BSP ---\n" );
SetDrawSurfacesBuffer();
- mapDrawSurfs = safe_malloc( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
- memset( mapDrawSurfs, 0, sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
+ mapDrawSurfs = safe_malloc0( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
numMapDrawSurfs = 0;
tempSource[ 0 ] = '\0';
numBSPDrawVerts = n;
numBSPDrawVertsBuffer = numBSPDrawVerts;
- bspDrawVerts = safe_malloc_info( sizeof( bspDrawVert_t ) * numBSPDrawVertsBuffer, "IncDrawVerts" );
-
- memset( bspDrawVerts, 0, n * sizeof( bspDrawVert_t ) );
+ bspDrawVerts = safe_malloc0_info( sizeof( bspDrawVert_t ) * numBSPDrawVertsBuffer, "IncDrawVerts" );
}
int numBSPDrawSurfacesBuffer = 0;
numBSPDrawSurfacesBuffer = MAX_MAP_DRAW_SURFS;
- bspDrawSurfaces = safe_malloc_info( sizeof( bspDrawSurface_t ) * numBSPDrawSurfacesBuffer, "IncDrawSurfaces" );
-
- memset( bspDrawSurfaces, 0, MAX_MAP_DRAW_SURFS * sizeof( bspDrawSurface_t ) );
+ bspDrawSurfaces = safe_malloc0_info( sizeof( bspDrawSurface_t ) * numBSPDrawSurfacesBuffer, "IncDrawSurfaces" );
}
void SetDrawSurfaces( int n ){
numBSPDrawSurfaces = n;
numBSPDrawSurfacesBuffer = numBSPDrawSurfaces;
- bspDrawSurfaces = safe_malloc_info( sizeof( bspDrawSurface_t ) * numBSPDrawSurfacesBuffer, "IncDrawSurfaces" );
-
- memset( bspDrawSurfaces, 0, n * sizeof( bspDrawSurface_t ) );
+ bspDrawSurfaces = safe_malloc0_info( sizeof( bspDrawSurface_t ) * numBSPDrawSurfacesBuffer, "IncDrawSurfaces" );
}
void BSPFilesCleanup(){
/* allocate and clear new epair */
- e = safe_malloc( sizeof( epair_t ) );
- memset( e, 0, sizeof( epair_t ) );
+ e = safe_malloc0( sizeof( epair_t ) );
/* handle key */
if ( strlen( token ) >= ( MAX_KEY - 1 ) ) {
/* allocate output buffer */
size = numBSPBrushSides * sizeof( *buffer );
- buffer = safe_malloc( size );
- memset( buffer, 0, size );
+ buffer = safe_malloc0( size );
/* convert */
in = bspBrushSides;
/* allocate output buffer */
size = numBSPDrawSurfaces * sizeof( *buffer );
- buffer = safe_malloc( size );
- memset( buffer, 0, size );
+ buffer = safe_malloc0( size );
/* convert */
in = bspDrawSurfaces;
/* allocate output buffer */
size = numBSPDrawVerts * sizeof( *buffer );
- buffer = safe_malloc( size );
- memset( buffer, 0, size );
+ buffer = safe_malloc0( size );
/* convert */
in = bspDrawVerts;
numBSPGridPoints = GetLumpElements( (bspHeader_t*) header, LUMP_LIGHTGRID, sizeof( *in ) );
/* allocate buffer */
- bspGridPoints = safe_malloc( numBSPGridPoints * sizeof( *bspGridPoints ) );
- memset( bspGridPoints, 0, numBSPGridPoints * sizeof( *bspGridPoints ) );
+ bspGridPoints = safe_malloc0( numBSPGridPoints * sizeof( *bspGridPoints ) );
/* copy */
in = GetLump( (bspHeader_t*) header, LUMP_LIGHTGRID );
numBSPGridPoints = GetLumpElements( (bspHeader_t*) header, LUMP_LIGHTARRAY, sizeof( *inArray ) );
/* allocate buffer */
- bspGridPoints = safe_malloc( numBSPGridPoints * sizeof( *bspGridPoints ) );
- memset( bspGridPoints, 0, numBSPGridPoints * sizeof( *bspGridPoints ) );
+ bspGridPoints = safe_malloc0( numBSPGridPoints * sizeof( *bspGridPoints ) );
/* copy */
inArray = GetLump( (bspHeader_t*) header, LUMP_LIGHTARRAY );
int i;
SetDrawSurfacesBuffer();
- mapDrawSurfs = safe_malloc( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
- memset( mapDrawSurfs, 0, sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
+ mapDrawSurfs = safe_malloc0( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
numMapDrawSurfs = 0;
BeginBSPFile();
ds2->lightmapScale = ds->lightmapScale;
ds2->shadeAngleDegrees = ds->shadeAngleDegrees;
ds2->numVerts = w->numpoints;
- ds2->verts = safe_malloc( ds2->numVerts * sizeof( *ds2->verts ) );
- memset( ds2->verts, 0, ds2->numVerts * sizeof( *ds2->verts ) );
+ ds2->verts = safe_malloc0( ds2->numVerts * sizeof( *ds2->verts ) );
/* set vertexes */
for ( i = 0; i < ds2->numVerts; i++ )
face_t *AllocBspFace( void ) {
face_t *f;
- f = safe_malloc( sizeof( *f ) );
- memset( f, 0, sizeof( *f ) );
+ f = safe_malloc0( sizeof( *f ) );
return f;
}
/* create a light */
numSunLights++;
- light = safe_malloc( sizeof( *light ) );
- memset( light, 0, sizeof( *light ) );
+ light = safe_malloc0( sizeof( *light ) );
light->next = lights;
lights = light;
/* create a light */
numPointLights++;
- light = safe_malloc( sizeof( *light ) );
- memset( light, 0, sizeof( *light ) );
+ light = safe_malloc0( sizeof( *light ) );
light->next = lights;
lights = light;
VectorScale( origin, 0.5f, origin );
/* create a light */
- light = safe_malloc( sizeof( *light ) );
- memset( light, 0, sizeof( *light ) );
+ light = safe_malloc0( sizeof( *light ) );
light->next = lights;
lights = light;
numBSPGridPoints = numRawGridPoints;
/* allocate lightgrid */
- rawGridPoints = safe_malloc( numRawGridPoints * sizeof( *rawGridPoints ) );
- memset( rawGridPoints, 0, numRawGridPoints * sizeof( *rawGridPoints ) );
+ rawGridPoints = safe_malloc0( numRawGridPoints * sizeof( *rawGridPoints ) );
if ( bspGridPoints != NULL ) {
free( bspGridPoints );
}
- bspGridPoints = safe_malloc( numBSPGridPoints * sizeof( *bspGridPoints ) );
- memset( bspGridPoints, 0, numBSPGridPoints * sizeof( *bspGridPoints ) );
+ bspGridPoints = safe_malloc0( numBSPGridPoints * sizeof( *bspGridPoints ) );
/* clear lightgrid */
for ( i = 0; i < numRawGridPoints; i++ )
}
/* create a light */
- light = safe_malloc( sizeof( *light ) );
- memset( light, 0, sizeof( *light ) );
+ light = safe_malloc0( sizeof( *light ) );
/* attach it */
ThreadLock();
/* optionally create a point splashsplash light for first pass */
if ( original && si->backsplashFraction > 0 ) {
/* allocate a new point light */
- splash = safe_malloc( sizeof( *splash ) );
- memset( splash, 0, sizeof( *splash ) );
+ splash = safe_malloc0( sizeof( *splash ) );
splash->next = lights;
lights = splash;
/* allocate shade angle table */
- shadeAngles = safe_malloc( numBSPDrawVerts * sizeof( float ) );
- memset( shadeAngles, 0, numBSPDrawVerts * sizeof( float ) );
+ shadeAngles = safe_malloc0( numBSPDrawVerts * sizeof( float ) );
/* allocate smoothed table */
cs = ( numBSPDrawVerts / 8 ) + 1;
- smoothed = safe_malloc( cs );
- memset( smoothed, 0, cs );
+ smoothed = safe_malloc0( cs );
/* set default shade angle */
defaultShadeAngle = DEG2RAD( shadeAngleDegrees );
if ( lm->superLuxels[ lightmapNum ] == NULL ) {
/* allocate sampling lightmap storage */
size = lm->sw * lm->sh * SUPER_LUXEL_SIZE * sizeof( float );
- lm->superLuxels[ lightmapNum ] = safe_malloc( size );
- memset( lm->superLuxels[ lightmapNum ], 0, size );
+ lm->superLuxels[ lightmapNum ] = safe_malloc0( size );
}
/* set style */
/* allocate a buffer and set it up */
buffer = safe_malloc( width * height * 3 + 18 );
+ /* we may also use safe_malloc0 on the whole instead,
+ * this would just be a bit slower */
memset( buffer, 0, 18 );
buffer[ 2 ] = 2;
buffer[ 12 ] = width & 255;
/* for planar surfaces, create lightmap vectors for st->xyz conversion */
if ( VectorLength( ds->lightmapVecs[ 2 ] ) || 1 ) { /* ydnar: can't remember what exactly i was thinking here... */
/* allocate space for the vectors */
- lm->vecs = safe_malloc( 3 * sizeof( vec3_t ) );
- memset( lm->vecs, 0, 3 * sizeof( vec3_t ) );
+ lm->vecs = safe_malloc0( 3 * sizeof( vec3_t ) );
VectorCopy( ds->lightmapVecs[ 2 ], lm->vecs[ 2 ] );
/* project stepped lightmap blocks and subtract to get planevecs */
/* allocate a list of surface clusters */
numSurfaceClusters = 0;
maxSurfaceClusters = numBSPLeafSurfaces;
- surfaceClusters = safe_malloc( maxSurfaceClusters * sizeof( *surfaceClusters ) );
- memset( surfaceClusters, 0, maxSurfaceClusters * sizeof( *surfaceClusters ) );
+ surfaceClusters = safe_malloc0( maxSurfaceClusters * sizeof( *surfaceClusters ) );
/* allocate a list for per-surface info */
- surfaceInfos = safe_malloc( numBSPDrawSurfaces * sizeof( *surfaceInfos ) );
- memset( surfaceInfos, 0, numBSPDrawSurfaces * sizeof( *surfaceInfos ) );
+ surfaceInfos = safe_malloc0( numBSPDrawSurfaces * sizeof( *surfaceInfos ) );
for ( i = 0; i < numBSPDrawSurfaces; i++ )
surfaceInfos[ i ].childSurfaceNum = -1;
/* allocate a list of surface indexes to be sorted */
- sortSurfaces = safe_malloc( numBSPDrawSurfaces * sizeof( int ) );
- memset( sortSurfaces, 0, numBSPDrawSurfaces * sizeof( int ) );
+ sortSurfaces = safe_malloc0( numBSPDrawSurfaces * sizeof( int ) );
/* walk each model in the bsp */
for ( i = 0; i < numBSPModels; i++ )
/* allocate a list of surfaces that would go into raw lightmaps */
numLightSurfaces = 0;
- lightSurfaces = safe_malloc( numSurfsLightmapped * sizeof( int ) );
- memset( lightSurfaces, 0, numSurfsLightmapped * sizeof( int ) );
+ lightSurfaces = safe_malloc0( numSurfsLightmapped * sizeof( int ) );
/* allocate a list of raw lightmaps */
numRawSuperLuxels = 0;
numRawLightmaps = 0;
- rawLightmaps = safe_malloc( numSurfsLightmapped * sizeof( *rawLightmaps ) );
- memset( rawLightmaps, 0, numSurfsLightmapped * sizeof( *rawLightmaps ) );
+ rawLightmaps = safe_malloc0( numSurfsLightmapped * sizeof( *rawLightmaps ) );
/* walk the list of sorted surfaces */
for ( i = 0; i < numBSPDrawSurfaces; i++ )
/* allocate vertex luxel storage */
for ( k = 0; k < MAX_LIGHTMAPS; k++ )
{
- vertexLuxels[ k ] = safe_malloc( numBSPDrawVerts * VERTEX_LUXEL_SIZE * sizeof( float ) );
- memset( vertexLuxels[ k ], 0, numBSPDrawVerts * VERTEX_LUXEL_SIZE * sizeof( float ) );
- radVertexLuxels[ k ] = safe_malloc( numBSPDrawVerts * VERTEX_LUXEL_SIZE * sizeof( float ) );
- memset( radVertexLuxels[ k ], 0, numBSPDrawVerts * VERTEX_LUXEL_SIZE * sizeof( float ) );
+ vertexLuxels[ k ] = safe_malloc0( numBSPDrawVerts * VERTEX_LUXEL_SIZE * sizeof( float ) );
+ radVertexLuxels[ k ] = safe_malloc0( numBSPDrawVerts * VERTEX_LUXEL_SIZE * sizeof( float ) );
}
/* emit some stats */
olm->numShaders = 0;
/* allocate buffers */
- olm->lightBits = safe_malloc( ( olm->customWidth * olm->customHeight / 8 ) + 8 );
- memset( olm->lightBits, 0, ( olm->customWidth * olm->customHeight / 8 ) + 8 );
- olm->bspLightBytes = safe_malloc( olm->customWidth * olm->customHeight * 3 );
- memset( olm->bspLightBytes, 0, olm->customWidth * olm->customHeight * 3 );
+ olm->lightBits = safe_malloc0( ( olm->customWidth * olm->customHeight / 8 ) + 8 );
+ olm->bspLightBytes = safe_malloc0( olm->customWidth * olm->customHeight * 3 );
if ( deluxemap ) {
- olm->bspDirBytes = safe_malloc( olm->customWidth * olm->customHeight * 3 );
- memset( olm->bspDirBytes, 0, olm->customWidth * olm->customHeight * 3 );
+ olm->bspDirBytes = safe_malloc0( olm->customWidth * olm->customHeight * 3 );
}
}
/* allocate bsp luxel storage */
if ( lm->bspLuxels[ lightmapNum ] == NULL ) {
size = lm->w * lm->h * BSP_LUXEL_SIZE * sizeof( float );
- lm->bspLuxels[ lightmapNum ] = safe_malloc( size );
- memset( lm->bspLuxels[ lightmapNum ], 0, size );
+ lm->bspLuxels[ lightmapNum ] = safe_malloc0( size );
}
/* allocate radiosity lightmap storage */
else
{
numBSPLightBytes = ( numBSPLightmaps * game->lightmapSize * game->lightmapSize * 3 );
- bspLightBytes = safe_malloc( numBSPLightBytes );
- memset( bspLightBytes, 0, numBSPLightBytes );
+ bspLightBytes = safe_malloc0( numBSPLightBytes );
}
/* walk the list of output lightmaps */
}
/* create a new index map */
- im = safe_malloc( sizeof( *im ) );
- memset( im, 0, sizeof( *im ) );
+ im = safe_malloc0( sizeof( *im ) );
/* set it up */
im->w = w;
/* set particulars */
ds->numVerts = PicoGetSurfaceNumVertexes( surface );
- ds->verts = safe_malloc( ds->numVerts * sizeof( ds->verts[ 0 ] ) );
- memset( ds->verts, 0, ds->numVerts * sizeof( ds->verts[ 0 ] ) );
+ ds->verts = safe_malloc0( ds->numVerts * sizeof( ds->verts[ 0 ] ) );
ds->numIndexes = PicoGetSurfaceNumIndexes( surface );
- ds->indexes = safe_malloc( ds->numIndexes * sizeof( ds->indexes[ 0 ] ) );
- memset( ds->indexes, 0, ds->numIndexes * sizeof( ds->indexes[ 0 ] ) );
+ ds->indexes = safe_malloc0( ds->numIndexes * sizeof( ds->indexes[ 0 ] ) );
/* copy vertexes */
for ( i = 0; i < ds->numVerts; i++ )
}
/* allocate patch mesh */
- pm = safe_malloc( sizeof( *pm ) );
- memset( pm, 0, sizeof( *pm ) );
+ pm = safe_malloc0( sizeof( *pm ) );
/* ydnar: add entity/brush numbering */
pm->entityNum = mapEnt->mapEntityNum;
if ( !patchCount ) {
return;
}
- bordering = safe_malloc( patchCount * patchCount );
- memset( bordering, 0, patchCount * patchCount );
+ bordering = safe_malloc0( patchCount * patchCount );
// build the bordering matrix
for ( k = 0 ; k < patchCount ; k++ ) {
c_peak_portals = c_active_portals;
}
- p = safe_malloc( sizeof( portal_t ) );
- memset( p, 0, sizeof( portal_t ) );
+ p = safe_malloc0( sizeof( portal_t ) );
return p;
}
}
/* allocate sun */
- sun = safe_malloc( sizeof( *sun ) );
- memset( sun, 0, sizeof( *sun ) );
+ sun = safe_malloc0( sizeof( *sun ) );
/* set style */
sun->style = si->lightStyle;
surfaceModel_t *model;
/* allocate new model and attach it */
- model = safe_malloc( sizeof( *model ) );
- memset( model, 0, sizeof( *model ) );
+ model = safe_malloc0( sizeof( *model ) );
model->next = si->surfaceModel;
si->surfaceModel = model;
/* allocate new foliage struct and attach it */
- foliage = safe_malloc( sizeof( *foliage ) );
- memset( foliage, 0, sizeof( *foliage ) );
+ foliage = safe_malloc0( sizeof( *foliage ) );
foliage->next = si->foliage;
si->foliage = foliage;
alpha = ( !Q_stricmp( token, "q3map_alphaGen" ) || !Q_stricmp( token, "q3map_alphaMod" ) ) ? 1 : 0;
/* allocate new colormod */
- cm = safe_malloc( sizeof( *cm ) );
- memset( cm, 0, sizeof( *cm ) );
+ cm = safe_malloc0( sizeof( *cm ) );
/* attach to shader */
if ( si->colorMod == NULL ) {
ds->sampleSize = b->lightmapSampleSize;
ds->lightmapScale = b->lightmapScale;
ds->numVerts = w->numpoints;
- ds->verts = safe_malloc( ds->numVerts * sizeof( *ds->verts ) );
- memset( ds->verts, 0, ds->numVerts * sizeof( *ds->verts ) );
+ ds->verts = safe_malloc0( ds->numVerts * sizeof( *ds->verts ) );
/* compute s/t coordinates from brush primitive texture matrix (compute axis base) */
ComputeAxisBase( mapplanes[ s->planenum ].normal, texX, texY );
VectorCopy( p->plane.normal, ds->lightmapVecs[ 2 ] );
ds->fogNum = -1;
ds->numVerts = w->numpoints;
- ds->verts = safe_malloc( ds->numVerts * sizeof( *ds->verts ) );
- memset( ds->verts, 0, ds->numVerts * sizeof( *ds->verts ) );
+ ds->verts = safe_malloc0( ds->numVerts * sizeof( *ds->verts ) );
/* walk the winding */
for ( i = 0; i < ds->numVerts; i++ )
ds->shaderInfo = si;
ds->fogNum = -1;
ds->numVerts = 8;
- ds->verts = safe_malloc( ds->numVerts * sizeof( *ds->verts ) );
- memset( ds->verts, 0, ds->numVerts * sizeof( *ds->verts ) );
+ ds->verts = safe_malloc0( ds->numVerts * sizeof( *ds->verts ) );
ds->numIndexes = 36;
- ds->indexes = safe_malloc( ds->numIndexes * sizeof( *ds->indexes ) );
- memset( ds->indexes, 0, ds->numIndexes * sizeof( *ds->indexes ) );
+ ds->indexes = safe_malloc0( ds->numIndexes * sizeof( *ds->indexes ) );
/* set verts */
VectorSet( ds->verts[ 0 ].xyz, fogMins[ 0 ], fogMins[ 1 ], fogMins[ 2 ] );
ds->fogNum = src->fogNum;
/* add a drawvert for every instance */
- verts = safe_malloc( ( ds->numVerts + ds->numFoliageInstances ) * sizeof( *verts ) );
- memset( verts, 0, ( ds->numVerts + ds->numFoliageInstances ) * sizeof( *verts ) );
+ verts = safe_malloc0( ( ds->numVerts + ds->numFoliageInstances ) * sizeof( *verts ) );
memcpy( verts, ds->verts, ds->numVerts * sizeof( *verts ) );
free( ds->verts );
ds->verts = verts;
/* add a new vertex at the beginning of the surface */
verts = safe_malloc( ( ds->numVerts + 1 ) * sizeof( bspDrawVert_t ) );
+ /* beware to only zero the new vertexi at the beginning, nor more! */
memset( verts, 0, sizeof( bspDrawVert_t ) );
memcpy( &verts[ 1 ], ds->verts, ds->numVerts * sizeof( bspDrawVert_t ) );
free( ds->verts );
Sys_FPrintf( SYS_VRB, "--- SmoothMetaTriangles ---\n" );
/* allocate shade angle table */
- shadeAngles = safe_malloc( numMetaVerts * sizeof( float ) );
- memset( shadeAngles, 0, numMetaVerts * sizeof( float ) );
+ shadeAngles = safe_malloc0( numMetaVerts * sizeof( float ) );
/* allocate smoothed table */
cs = ( numMetaVerts / 8 ) + 1;
- smoothed = safe_malloc( cs );
- memset( smoothed, 0, cs );
+ smoothed = safe_malloc0( cs );
/* set default shade angle */
defaultShadeAngle = DEG2RAD( npDegrees );
}
size = (int)( (size_t)( (fixedWinding_t *)0 )->points[points] );
- w = safe_malloc( size );
- memset( w, 0, size );
+ w = safe_malloc0( size );
return w;
}
portallongs = portalbytes / sizeof( long );
// each file portal is split into two memory portals
- portals = safe_malloc( 2 * numportals * sizeof( vportal_t ) );
- memset( portals, 0, 2 * numportals * sizeof( vportal_t ) );
+ portals = safe_malloc0( 2 * numportals * sizeof( vportal_t ) );
- leafs = safe_malloc( portalclusters * sizeof( leaf_t ) );
- memset( leafs, 0, portalclusters * sizeof( leaf_t ) );
+ leafs = safe_malloc0( portalclusters * sizeof( leaf_t ) );
for ( i = 0; i < portalclusters; i++ )
leafs[i].merged = -1;
}
- faces = safe_malloc( 2 * numfaces * sizeof( vportal_t ) );
- memset( faces, 0, 2 * numfaces * sizeof( vportal_t ) );
+ faces = safe_malloc0( 2 * numfaces * sizeof( vportal_t ) );
- faceleafs = safe_malloc( portalclusters * sizeof( leaf_t ) );
- memset( faceleafs, 0, portalclusters * sizeof( leaf_t ) );
+ faceleafs = safe_malloc0( portalclusters * sizeof( leaf_t ) );
for ( i = 0, p = faces; i < numfaces; i++ )
{
continue;
}
- passage = (passage_t *) safe_malloc( sizeof( passage_t ) + portalbytes );
- memset( passage, 0, sizeof( passage_t ) + portalbytes );
+ passage = (passage_t *) safe_malloc0( sizeof( passage_t ) + portalbytes );
numseperators = AddSeperators( portal->winding, target->winding, qfalse, seperators, MAX_SEPERATORS * 2 );
numseperators += AddSeperators( target->winding, portal->winding, qtrue, &seperators[numseperators], MAX_SEPERATORS * 2 - numseperators );
return;
}
- p->portalfront = safe_malloc( portalbytes );
- memset( p->portalfront, 0, portalbytes );
+ p->portalfront = safe_malloc0( portalbytes );
- p->portalflood = safe_malloc( portalbytes );
- memset( p->portalflood, 0, portalbytes );
+ p->portalflood = safe_malloc0( portalbytes );
- p->portalvis = safe_malloc( portalbytes );
- memset( p->portalvis, 0, portalbytes );
+ p->portalvis = safe_malloc0( portalbytes );
for ( j = 0, tp = portals ; j < numportals * 2 ; j++, tp++ )
{