diff options
author | Matt Turner <[email protected]> | 2012-09-03 19:44:00 -0700 |
---|---|---|
committer | Matt Turner <[email protected]> | 2012-09-05 22:28:50 -0700 |
commit | 2b7a972e3f36bfcdc6fbe2b59d7ffdcde49c9405 (patch) | |
tree | 4b9504b4799e9d29363690fb9083ac4bbcf78d51 /src/mesa/swrast | |
parent | 812931f602ff913a51a608a9b1b6826b7f2bfae0 (diff) |
Don't cast the return value of malloc/realloc
This patch has been generated by the following Coccinelle semantic
patch:
// Don't cast the return value of malloc/realloc.
//
// Casting the return value of malloc/realloc only stands to hide
// errors.
@@
type T;
expression E1, E2;
@@
- (T)
(
_mesa_align_calloc(E1, E2)
|
_mesa_align_malloc(E1, E2)
|
calloc(E1, E2)
|
malloc(E1)
|
realloc(E1, E2)
)
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r-- | src/mesa/swrast/s_context.c | 12 | ||||
-rw-r--r-- | src/mesa/swrast/s_copypix.c | 10 | ||||
-rw-r--r-- | src/mesa/swrast/s_depth.c | 4 | ||||
-rw-r--r-- | src/mesa/swrast/s_drawpix.c | 4 | ||||
-rw-r--r-- | src/mesa/swrast/s_texcombine.c | 8 | ||||
-rw-r--r-- | src/mesa/swrast/s_texfilter.c | 2 | ||||
-rw-r--r-- | src/mesa/swrast/s_texture.c | 2 | ||||
-rw-r--r-- | src/mesa/swrast/s_zoom.c | 4 |
8 files changed, 23 insertions, 23 deletions
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index 53497bc9c40..d5acaee8312 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -720,7 +720,7 @@ GLboolean _swrast_CreateContext( struct gl_context *ctx ) { GLuint i; - SWcontext *swrast = (SWcontext *) calloc(1, sizeof(SWcontext)); + SWcontext *swrast = calloc(1, sizeof(SWcontext)); #ifdef _OPENMP const GLuint maxThreads = omp_get_max_threads(); #else @@ -775,7 +775,7 @@ _swrast_CreateContext( struct gl_context *ctx ) * using multiple threads, it is necessary to have one SpanArrays instance * per thread. */ - swrast->SpanArrays = (SWspanarrays *) malloc(maxThreads * sizeof(SWspanarrays)); + swrast->SpanArrays = malloc(maxThreads * sizeof(SWspanarrays)); if (!swrast->SpanArrays) { free(swrast); return GL_FALSE; @@ -803,10 +803,10 @@ _swrast_CreateContext( struct gl_context *ctx ) ctx->swrast_context = swrast; - swrast->stencil_temp.buf1 = (GLubyte *) malloc(SWRAST_MAX_WIDTH * sizeof(GLubyte)); - swrast->stencil_temp.buf2 = (GLubyte *) malloc(SWRAST_MAX_WIDTH * sizeof(GLubyte)); - swrast->stencil_temp.buf3 = (GLubyte *) malloc(SWRAST_MAX_WIDTH * sizeof(GLubyte)); - swrast->stencil_temp.buf4 = (GLubyte *) malloc(SWRAST_MAX_WIDTH * sizeof(GLubyte)); + swrast->stencil_temp.buf1 = malloc(SWRAST_MAX_WIDTH * sizeof(GLubyte)); + swrast->stencil_temp.buf2 = malloc(SWRAST_MAX_WIDTH * sizeof(GLubyte)); + swrast->stencil_temp.buf3 = malloc(SWRAST_MAX_WIDTH * sizeof(GLubyte)); + swrast->stencil_temp.buf4 = malloc(SWRAST_MAX_WIDTH * sizeof(GLubyte)); if (!swrast->stencil_temp.buf1 || !swrast->stencil_temp.buf2 || diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c index cf419c328d6..bbd1f228c39 100644 --- a/src/mesa/swrast/s_copypix.c +++ b/src/mesa/swrast/s_copypix.c @@ -139,7 +139,7 @@ copy_rgba_pixels(struct gl_context *ctx, GLint srcx, GLint srcy, span.arrayAttribs = FRAG_BIT_COL0; /* we'll fill in COL0 attrib values */ if (overlapping) { - tmpImage = (GLfloat *) malloc(width * height * sizeof(GLfloat) * 4); + tmpImage = malloc(width * height * sizeof(GLfloat) * 4); if (!tmpImage) { _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" ); return; @@ -286,7 +286,7 @@ copy_depth_pixels( struct gl_context *ctx, GLint srcx, GLint srcy, if (overlapping) { GLint ssy = sy; - tmpImage = (GLfloat *) malloc(width * height * sizeof(GLfloat)); + tmpImage = malloc(width * height * sizeof(GLfloat)); if (!tmpImage) { _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" ); return; @@ -303,7 +303,7 @@ copy_depth_pixels( struct gl_context *ctx, GLint srcx, GLint srcy, p = NULL; } - depth = (GLfloat *) malloc(width * sizeof(GLfloat)); + depth = malloc(width * sizeof(GLfloat)); if (!depth) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels()"); goto end; @@ -383,7 +383,7 @@ copy_stencil_pixels( struct gl_context *ctx, GLint srcx, GLint srcy, if (overlapping) { GLint ssy = sy; - tmpImage = (GLubyte *) malloc(width * height * sizeof(GLubyte)); + tmpImage = malloc(width * height * sizeof(GLubyte)); if (!tmpImage) { _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" ); return; @@ -400,7 +400,7 @@ copy_stencil_pixels( struct gl_context *ctx, GLint srcx, GLint srcy, p = NULL; } - stencil = (GLubyte *) malloc(width * sizeof(GLubyte)); + stencil = malloc(width * sizeof(GLubyte)); if (!stencil) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels()"); goto end; diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c index 26126a9329f..969b75f07a6 100644 --- a/src/mesa/swrast/s_depth.c +++ b/src/mesa/swrast/s_depth.c @@ -311,7 +311,7 @@ _swrast_depth_test_span(struct gl_context *ctx, SWspan *span) } else { /* copy Z buffer values into temp buffer (32-bit Z values) */ - zBufferTemp = (GLuint *) malloc(count * sizeof(GLuint)); + zBufferTemp = malloc(count * sizeof(GLuint)); if (!zBufferTemp) return 0; @@ -422,7 +422,7 @@ _swrast_depth_bounds_test( struct gl_context *ctx, SWspan *span ) GLuint *zBufferTemp; const GLuint *zBufferVals; - zBufferTemp = (GLuint *) malloc(count * sizeof(GLuint)); + zBufferTemp = malloc(count * sizeof(GLuint)); if (!zBufferTemp) { /* don't generate a stream of OUT_OF_MEMORY errors here */ return GL_FALSE; diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index 1fa64c37829..93d2d352922 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -267,7 +267,7 @@ draw_stencil_pixels( struct gl_context *ctx, GLint x, GLint y, GLint row; GLubyte *values; - values = (GLubyte *) malloc(width * sizeof(GLubyte)); + values = malloc(width * sizeof(GLubyte)); if (!values) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels"); return; @@ -592,7 +592,7 @@ draw_depth_stencil_pixels(struct gl_context *ctx, GLint x, GLint y, GLuint *zValues; /* 32-bit Z values */ GLint i; - zValues = (GLuint *) malloc(width * sizeof(GLuint)); + zValues = malloc(width * sizeof(GLuint)); if (!zValues) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels"); return; diff --git a/src/mesa/swrast/s_texcombine.c b/src/mesa/swrast/s_texcombine.c index 9c745d1183b..1a2db35e286 100644 --- a/src/mesa/swrast/s_texcombine.c +++ b/src/mesa/swrast/s_texcombine.c @@ -98,14 +98,14 @@ texture_combine( struct gl_context *ctx, GLuint unit, GLchan (*rgbaChan)[4] = span->array->rgba; /* alloc temp pixel buffers */ - rgba = (float4_array) malloc(4 * n * sizeof(GLfloat)); + rgba = malloc(4 * n * sizeof(GLfloat)); if (!rgba) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture_combine"); return; } for (i = 0; i < numArgsRGB || i < numArgsA; i++) { - ccolor[i] = (float4_array) malloc(4 * n * sizeof(GLfloat)); + ccolor[i] = malloc(4 * n * sizeof(GLfloat)); if (!ccolor[i]) { while (i) { free(ccolor[i]); @@ -611,7 +611,7 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span ) * thread. */ swrast->TexelBuffer = - (GLfloat *) malloc(ctx->Const.MaxTextureImageUnits * maxThreads * + malloc(ctx->Const.MaxTextureImageUnits * maxThreads * SWRAST_MAX_WIDTH * 4 * sizeof(GLfloat)); if (!swrast->TexelBuffer) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture_combine"); @@ -619,7 +619,7 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span ) } } - primary_rgba = (float4_array) malloc(span->end * 4 * sizeof(GLfloat)); + primary_rgba = malloc(span->end * 4 * sizeof(GLfloat)); if (!primary_rgba) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture_span"); diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c index 152b1ff3efa..0a91cca06b0 100644 --- a/src/mesa/swrast/s_texfilter.c +++ b/src/mesa/swrast/s_texfilter.c @@ -1618,7 +1618,7 @@ create_filter_table(void) { GLuint i; if (!weightLut) { - weightLut = (GLfloat *) malloc(WEIGHT_LUT_SIZE * sizeof(GLfloat)); + weightLut = malloc(WEIGHT_LUT_SIZE * sizeof(GLfloat)); for (i = 0; i < WEIGHT_LUT_SIZE; ++i) { GLfloat alpha = 2; diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c index 1b73d46e49b..defe669941f 100644 --- a/src/mesa/swrast/s_texture.c +++ b/src/mesa/swrast/s_texture.c @@ -83,7 +83,7 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx, * We allocate the array for 1D/2D textures too in order to avoid special- * case code in the texstore routines. */ - swImg->ImageOffsets = (GLuint *) malloc(texImage->Depth * sizeof(GLuint)); + swImg->ImageOffsets = malloc(texImage->Depth * sizeof(GLuint)); if (!swImg->ImageOffsets) return GL_FALSE; diff --git a/src/mesa/swrast/s_zoom.c b/src/mesa/swrast/s_zoom.c index 9304002d224..24bfa22bfa0 100644 --- a/src/mesa/swrast/s_zoom.c +++ b/src/mesa/swrast/s_zoom.c @@ -375,7 +375,7 @@ _swrast_write_zoomed_stencil_span(struct gl_context *ctx, GLint imgX, GLint imgY ASSERT(zoomedWidth > 0); ASSERT(zoomedWidth <= SWRAST_MAX_WIDTH); - zoomedVals = (GLubyte *) malloc(zoomedWidth * sizeof(GLubyte)); + zoomedVals = malloc(zoomedWidth * sizeof(GLubyte)); if (!zoomedVals) return; @@ -420,7 +420,7 @@ _swrast_write_zoomed_z_span(struct gl_context *ctx, GLint imgX, GLint imgY, ASSERT(zoomedWidth > 0); ASSERT(zoomedWidth <= SWRAST_MAX_WIDTH); - zoomedVals = (GLuint *) malloc(zoomedWidth * sizeof(GLuint)); + zoomedVals = malloc(zoomedWidth * sizeof(GLuint)); if (!zoomedVals) return; |