summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2012-09-03 19:44:00 -0700
committerMatt Turner <[email protected]>2012-09-05 22:28:50 -0700
commit2b7a972e3f36bfcdc6fbe2b59d7ffdcde49c9405 (patch)
tree4b9504b4799e9d29363690fb9083ac4bbcf78d51 /src/mesa/main
parent812931f602ff913a51a608a9b1b6826b7f2bfae0 (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/main')
-rw-r--r--src/mesa/main/accum.c6
-rw-r--r--src/mesa/main/atifragshader.c2
-rw-r--r--src/mesa/main/attrib.c2
-rw-r--r--src/mesa/main/context.c4
-rw-r--r--src/mesa/main/cpuinfo.c2
-rw-r--r--src/mesa/main/debug.c18
-rw-r--r--src/mesa/main/dlist.c14
-rw-r--r--src/mesa/main/eval.c16
-rw-r--r--src/mesa/main/extensions.c2
-rw-r--r--src/mesa/main/format_unpack.c2
-rw-r--r--src/mesa/main/imports.c6
-rw-r--r--src/mesa/main/matrix.c2
-rw-r--r--src/mesa/main/mipmap.c8
-rw-r--r--src/mesa/main/mm.c8
-rw-r--r--src/mesa/main/pack.c34
-rw-r--r--src/mesa/main/readpix.c10
-rw-r--r--src/mesa/main/shaderapi.c8
-rw-r--r--src/mesa/main/texcompress_cpal.c2
-rw-r--r--src/mesa/main/texgetimage.c6
-rw-r--r--src/mesa/main/texstore.c24
-rw-r--r--src/mesa/main/transformfeedback.c2
-rw-r--r--src/mesa/main/uniforms.c2
-rw-r--r--src/mesa/main/version.c6
-rw-r--r--src/mesa/main/vsnprintf.c2
24 files changed, 93 insertions, 95 deletions
diff --git a/src/mesa/main/accum.c b/src/mesa/main/accum.c
index df6f219bf30..16c26168ad1 100644
--- a/src/mesa/main/accum.c
+++ b/src/mesa/main/accum.c
@@ -289,7 +289,7 @@ accum_or_load(struct gl_context *ctx, GLfloat value,
GLuint i, j;
GLfloat (*rgba)[4];
- rgba = (GLfloat (*)[4]) malloc(width * 4 * sizeof(GLfloat));
+ rgba = malloc(width * 4 * sizeof(GLfloat));
if (rgba) {
for (j = 0; j < height; j++) {
GLshort *acc = (GLshort *) accMap;
@@ -381,8 +381,8 @@ accum_return(struct gl_context *ctx, GLfloat value,
GLint i, j;
GLfloat (*rgba)[4], (*dest)[4];
- rgba = (GLfloat (*)[4]) malloc(width * 4 * sizeof(GLfloat));
- dest = (GLfloat (*)[4]) malloc(width * 4 * sizeof(GLfloat));
+ rgba = malloc(width * 4 * sizeof(GLfloat));
+ dest = malloc(width * 4 * sizeof(GLfloat));
if (rgba && dest) {
for (j = 0; j < height; j++) {
diff --git a/src/mesa/main/atifragshader.c b/src/mesa/main/atifragshader.c
index c74c999f808..080e8ee2284 100644
--- a/src/mesa/main/atifragshader.c
+++ b/src/mesa/main/atifragshader.c
@@ -352,11 +352,9 @@ _mesa_BeginFragmentShaderATI(void)
a start */
for (i = 0; i < MAX_NUM_PASSES_ATI; i++) {
ctx->ATIFragmentShader.Current->Instructions[i] =
- (struct atifs_instruction *)
calloc(1, sizeof(struct atifs_instruction) *
(MAX_NUM_INSTRUCTIONS_PER_PASS_ATI));
ctx->ATIFragmentShader.Current->SetupInst[i] =
- (struct atifs_setupinst *)
calloc(1, sizeof(struct atifs_setupinst) *
(MAX_NUM_FRAGMENT_REGISTERS_ATI));
}
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index b3d10d31edf..806cf09d8b6 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -398,7 +398,7 @@ _mesa_PushAttrib(GLbitfield mask)
if (mask & GL_POLYGON_STIPPLE_BIT) {
GLuint *stipple;
- stipple = (GLuint *) malloc( 32*sizeof(GLuint) );
+ stipple = malloc( 32*sizeof(GLuint) );
memcpy( stipple, ctx->PolygonStipple, 32*sizeof(GLuint) );
save_attrib_data(&head, GL_POLYGON_STIPPLE_BIT, stipple);
}
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index feddbaa7e64..0a1fb43f4fa 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -871,7 +871,7 @@ _mesa_alloc_dispatch_table(int size)
/* should never happen, but just in case */
numEntries = MAX2(numEntries, size);
- table = (struct _glapi_table *) malloc(numEntries * sizeof(_glapi_proc));
+ table = malloc(numEntries * sizeof(_glapi_proc));
if (table) {
_glapi_proc *entry = (_glapi_proc *) table;
GLint i;
@@ -1075,7 +1075,7 @@ _mesa_create_context(gl_api api,
ASSERT(visual);
/*ASSERT(driverContext);*/
- ctx = (struct gl_context *) calloc(1, sizeof(struct gl_context));
+ ctx = calloc(1, sizeof(struct gl_context));
if (!ctx)
return NULL;
diff --git a/src/mesa/main/cpuinfo.c b/src/mesa/main/cpuinfo.c
index 0d7971bcc47..41505f6378b 100644
--- a/src/mesa/main/cpuinfo.c
+++ b/src/mesa/main/cpuinfo.c
@@ -51,7 +51,7 @@ _mesa_get_cpu_string(void)
#define MAX_STRING 50
char *buffer;
- buffer = (char *) malloc(MAX_STRING);
+ buffer = malloc(MAX_STRING);
if (!buffer)
return NULL;
diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c
index 62b8e00c197..aee8ae2dc2d 100644
--- a/src/mesa/main/debug.c
+++ b/src/mesa/main/debug.c
@@ -283,7 +283,7 @@ write_texture_image(struct gl_texture_object *texObj,
GLubyte *buffer;
char s[100];
- buffer = (GLubyte *) malloc(img->Width * img->Height
+ buffer = malloc(img->Width * img->Height
* img->Depth * 4);
store = ctx->Pack; /* save */
@@ -332,7 +332,7 @@ _mesa_write_renderbuffer_image(const struct gl_renderbuffer *rb)
return;
}
- buffer = (GLubyte *) malloc(rb->Width * rb->Height * 4);
+ buffer = malloc(rb->Width * rb->Height * 4);
ctx->Driver.ReadPixels(ctx, 0, 0, rb->Width, rb->Height,
format, type, &ctx->DefaultPacking, buffer);
@@ -466,7 +466,7 @@ _mesa_dump_color_buffer(const char *filename)
const GLuint h = ctx->DrawBuffer->Height;
GLubyte *buf;
- buf = (GLubyte *) malloc(w * h * 4);
+ buf = malloc(w * h * 4);
_mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
_mesa_PixelStorei(GL_PACK_ALIGNMENT, 1);
@@ -498,8 +498,8 @@ _mesa_dump_depth_buffer(const char *filename)
GLubyte *buf2;
GLuint i;
- buf = (GLuint *) malloc(w * h * 4); /* 4 bpp */
- buf2 = (GLubyte *) malloc(w * h * 3); /* 3 bpp */
+ buf = malloc(w * h * 4); /* 4 bpp */
+ buf2 = malloc(w * h * 3); /* 3 bpp */
_mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
_mesa_PixelStorei(GL_PACK_ALIGNMENT, 1);
@@ -534,8 +534,8 @@ _mesa_dump_stencil_buffer(const char *filename)
GLubyte *buf2;
GLuint i;
- buf = (GLubyte *) malloc(w * h); /* 1 bpp */
- buf2 = (GLubyte *) malloc(w * h * 3); /* 3 bpp */
+ buf = malloc(w * h); /* 1 bpp */
+ buf2 = malloc(w * h * 3); /* 3 bpp */
_mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
_mesa_PixelStorei(GL_PACK_ALIGNMENT, 1);
@@ -579,7 +579,7 @@ _mesa_dump_image(const char *filename, const void *image, GLuint w, GLuint h,
}
else if (format == GL_RGBA && type == GL_FLOAT) {
/* convert floats to ubyte */
- GLubyte *buf = (GLubyte *) malloc(w * h * 4 * sizeof(GLubyte));
+ GLubyte *buf = malloc(w * h * 4 * sizeof(GLubyte));
const GLfloat *f = (const GLfloat *) image;
GLuint i;
for (i = 0; i < w * h * 4; i++) {
@@ -590,7 +590,7 @@ _mesa_dump_image(const char *filename, const void *image, GLuint w, GLuint h,
}
else if (format == GL_RED && type == GL_FLOAT) {
/* convert floats to ubyte */
- GLubyte *buf = (GLubyte *) malloc(w * h * sizeof(GLubyte));
+ GLubyte *buf = malloc(w * h * sizeof(GLubyte));
const GLfloat *f = (const GLfloat *) image;
GLuint i;
for (i = 0; i < w * h; i++) {
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 5a813e98ac3..40e69336478 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -573,7 +573,7 @@ make_list(GLuint name, GLuint count)
{
struct gl_display_list *dlist = CALLOC_STRUCT(gl_display_list);
dlist->Name = name;
- dlist->Head = (Node *) malloc(sizeof(Node) * count);
+ dlist->Head = malloc(sizeof(Node) * count);
dlist->Head[0].opcode = OPCODE_END_OF_LIST;
return dlist;
}
@@ -995,7 +995,7 @@ dlist_alloc(struct gl_context *ctx, OpCode opcode, GLuint bytes)
Node *newblock;
n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
n[0].opcode = OPCODE_CONTINUE;
- newblock = (Node *) malloc(sizeof(Node) * BLOCK_SIZE);
+ newblock = malloc(sizeof(Node) * BLOCK_SIZE);
if (!newblock) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "Building display list");
return NULL;
@@ -3190,7 +3190,7 @@ save_PixelMapfv(GLenum map, GLint mapsize, const GLfloat *values)
if (n) {
n[1].e = map;
n[2].i = mapsize;
- n[3].data = (void *) malloc(mapsize * sizeof(GLfloat));
+ n[3].data = malloc(mapsize * sizeof(GLfloat));
memcpy(n[3].data, (void *) values, mapsize * sizeof(GLfloat));
}
if (ctx->ExecuteFlag) {
@@ -5018,7 +5018,7 @@ save_LoadProgramNV(GLenum target, GLuint id, GLsizei len,
n = alloc_instruction(ctx, OPCODE_LOAD_PROGRAM_NV, 4);
if (n) {
- GLubyte *programCopy = (GLubyte *) malloc(len);
+ GLubyte *programCopy = malloc(len);
if (!programCopy) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
return;
@@ -5045,7 +5045,7 @@ save_RequestResidentProgramsNV(GLsizei num, const GLuint * ids)
n = alloc_instruction(ctx, OPCODE_TRACK_MATRIX_NV, 2);
if (n) {
- GLuint *idCopy = (GLuint *) malloc(num * sizeof(GLuint));
+ GLuint *idCopy = malloc(num * sizeof(GLuint));
if (!idCopy) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glRequestResidentProgramsNV");
return;
@@ -5216,7 +5216,7 @@ save_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte * name,
n = alloc_instruction(ctx, OPCODE_PROGRAM_NAMED_PARAMETER_NV, 6);
if (n) {
- GLubyte *nameCopy = (GLubyte *) malloc(len);
+ GLubyte *nameCopy = malloc(len);
if (!nameCopy) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramNamedParameter4fNV");
return;
@@ -5315,7 +5315,7 @@ save_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
n = alloc_instruction(ctx, OPCODE_PROGRAM_STRING_ARB, 4);
if (n) {
- GLubyte *programCopy = (GLubyte *) malloc(len);
+ GLubyte *programCopy = malloc(len);
if (!programCopy) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB");
return;
diff --git a/src/mesa/main/eval.c b/src/mesa/main/eval.c
index 487c4ce04d9..ca1b33bd2ed 100644
--- a/src/mesa/main/eval.c
+++ b/src/mesa/main/eval.c
@@ -218,7 +218,7 @@ GLfloat *_mesa_copy_map_points1f( GLenum target, GLint ustride, GLint uorder,
if (!points || !size)
return NULL;
- buffer = (GLfloat *) malloc(uorder * size * sizeof(GLfloat));
+ buffer = malloc(uorder * size * sizeof(GLfloat));
if (buffer)
for (i = 0, p = buffer; i < uorder; i++, points += ustride)
@@ -242,7 +242,7 @@ GLfloat *_mesa_copy_map_points1d( GLenum target, GLint ustride, GLint uorder,
if (!points || !size)
return NULL;
- buffer = (GLfloat *) malloc(uorder * size * sizeof(GLfloat));
+ buffer = malloc(uorder * size * sizeof(GLfloat));
if (buffer)
for (i = 0, p = buffer; i < uorder; i++, points += ustride)
@@ -286,9 +286,9 @@ GLfloat *_mesa_copy_map_points2f( GLenum target,
hsize = (uorder > vorder ? uorder : vorder)*size;
if(hsize>dsize)
- buffer = (GLfloat *) malloc((uorder*vorder*size+hsize)*sizeof(GLfloat));
+ buffer = malloc((uorder*vorder*size+hsize)*sizeof(GLfloat));
else
- buffer = (GLfloat *) malloc((uorder*vorder*size+dsize)*sizeof(GLfloat));
+ buffer = malloc((uorder*vorder*size+dsize)*sizeof(GLfloat));
/* compute the increment value for the u-loop */
uinc = ustride - vorder*vstride;
@@ -329,9 +329,9 @@ GLfloat *_mesa_copy_map_points2d(GLenum target,
hsize = (uorder > vorder ? uorder : vorder)*size;
if(hsize>dsize)
- buffer = (GLfloat *) malloc((uorder*vorder*size+hsize)*sizeof(GLfloat));
+ buffer = malloc((uorder*vorder*size+hsize)*sizeof(GLfloat));
else
- buffer = (GLfloat *) malloc((uorder*vorder*size+dsize)*sizeof(GLfloat));
+ buffer = malloc((uorder*vorder*size+dsize)*sizeof(GLfloat));
/* compute the increment value for the u-loop */
uinc = ustride - vorder*vstride;
@@ -940,7 +940,7 @@ init_1d_map( struct gl_1d_map *map, int n, const float *initial )
map->Order = 1;
map->u1 = 0.0;
map->u2 = 1.0;
- map->Points = (GLfloat *) malloc(n * sizeof(GLfloat));
+ map->Points = malloc(n * sizeof(GLfloat));
if (map->Points) {
GLint i;
for (i=0;i<n;i++)
@@ -961,7 +961,7 @@ init_2d_map( struct gl_2d_map *map, int n, const float *initial )
map->u2 = 1.0;
map->v1 = 0.0;
map->v2 = 1.0;
- map->Points = (GLfloat *) malloc(n * sizeof(GLfloat));
+ map->Points = malloc(n * sizeof(GLfloat));
if (map->Points) {
GLint i;
for (i=0;i<n;i++)
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 7e116bdd1b1..36e1fcf62db 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -867,7 +867,7 @@ _mesa_make_extension_string(struct gl_context *ctx)
if (extra_extensions != NULL)
length += 1 + strlen(extra_extensions); /* +1 for space */
- exts = (char *) calloc(ALIGN(length + 1, 4), sizeof(char));
+ exts = calloc(ALIGN(length + 1, 4), sizeof(char));
if (exts == NULL) {
free(extra_extensions);
return NULL;
diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index bd218520f77..7b46dfc791b 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -2078,7 +2078,7 @@ _mesa_unpack_ubyte_rgba_row(gl_format format, GLuint n,
default:
/* get float values, convert to ubyte */
{
- GLfloat *tmp = (GLfloat *) malloc(n * 4 * sizeof(GLfloat));
+ GLfloat *tmp = malloc(n * 4 * sizeof(GLfloat));
if (tmp) {
GLuint i;
_mesa_unpack_rgba_row(format, n, src, (GLfloat (*)[4]) tmp);
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index 9b5f856b0a8..2985ad777cf 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -97,7 +97,7 @@ _mesa_align_malloc(size_t bytes, unsigned long alignment)
ASSERT( alignment > 0 );
- ptr = (uintptr_t) malloc(bytes + alignment + sizeof(void *));
+ ptr = malloc(bytes + alignment + sizeof(void *));
if (!ptr)
return NULL;
@@ -146,7 +146,7 @@ _mesa_align_calloc(size_t bytes, unsigned long alignment)
ASSERT( alignment > 0 );
- ptr = (uintptr_t) calloc(1, bytes + alignment + sizeof(void *));
+ ptr = calloc(1, bytes + alignment + sizeof(void *));
if (!ptr)
return NULL;
@@ -527,7 +527,7 @@ _mesa_strdup( const char *s )
{
if (s) {
size_t l = strlen(s);
- char *s2 = (char *) malloc(l + 1);
+ char *s2 = malloc(l + 1);
if (s2)
strcpy(s2, s);
return s2;
diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c
index a6193071d5f..5c3569c16a7 100644
--- a/src/mesa/main/matrix.c
+++ b/src/mesa/main/matrix.c
@@ -671,7 +671,7 @@ init_matrix_stack( struct gl_matrix_stack *stack,
stack->MaxDepth = maxDepth;
stack->DirtyFlag = dirtyFlag;
/* The stack */
- stack->Stack = (GLmatrix *) calloc(maxDepth, sizeof(GLmatrix));
+ stack->Stack = calloc(maxDepth, sizeof(GLmatrix));
for (i = 0; i < maxDepth; i++) {
_math_matrix_ctr(&stack->Stack[i]);
}
diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
index 15373ba69b0..a2f3767a327 100644
--- a/src/mesa/main/mipmap.c
+++ b/src/mesa/main/mipmap.c
@@ -1939,7 +1939,7 @@ generate_mipmap_uncompressed(struct gl_context *ctx, GLenum target,
}
/* Map src texture image slices */
- srcMaps = (GLubyte **) calloc(srcDepth, sizeof(GLubyte *));
+ srcMaps = calloc(srcDepth, sizeof(GLubyte *));
if (srcMaps) {
for (slice = 0; slice < srcDepth; slice++) {
ctx->Driver.MapTextureImage(ctx, srcImage, slice,
@@ -1957,7 +1957,7 @@ generate_mipmap_uncompressed(struct gl_context *ctx, GLenum target,
}
/* Map dst texture image slices */
- dstMaps = (GLubyte **) calloc(dstDepth, sizeof(GLubyte *));
+ dstMaps = calloc(dstDepth, sizeof(GLubyte *));
if (dstMaps) {
for (slice = 0; slice < dstDepth; slice++) {
ctx->Driver.MapTextureImage(ctx, dstImage, slice,
@@ -2053,7 +2053,7 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum target,
/* allocate storage for the temporary, uncompressed image */
/* 20 extra bytes, just be safe when calling last FetchTexel */
temp_src_stride = _mesa_format_row_stride(temp_format, srcImage->Width);
- temp_src = (GLubyte *) malloc(temp_src_stride * srcImage->Height + 20);
+ temp_src = malloc(temp_src_stride * srcImage->Height + 20);
if (!temp_src) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "generate mipmaps");
return;
@@ -2102,7 +2102,7 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum target,
temp_dst_stride = _mesa_format_row_stride(temp_format, dstWidth);
if (!temp_dst) {
- temp_dst = (GLubyte *) malloc(temp_dst_stride * dstHeight);
+ temp_dst = malloc(temp_dst_stride * dstHeight);
if (!temp_dst) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "generate mipmaps");
break;
diff --git a/src/mesa/main/mm.c b/src/mesa/main/mm.c
index ab32123a403..473e90fc2d5 100644
--- a/src/mesa/main/mm.c
+++ b/src/mesa/main/mm.c
@@ -65,11 +65,11 @@ mmInit(unsigned ofs, unsigned size)
if (!size)
return NULL;
- heap = (struct mem_block *) calloc(1, sizeof(struct mem_block));
+ heap = calloc(1, sizeof(struct mem_block));
if (!heap)
return NULL;
- block = (struct mem_block *) calloc(1, sizeof(struct mem_block));
+ block = calloc(1, sizeof(struct mem_block));
if (!block) {
free(heap);
return NULL;
@@ -103,7 +103,7 @@ SliceBlock(struct mem_block *p,
/* break left [p, newblock, p->next], then p = newblock */
if (startofs > p->ofs) {
- newblock = (struct mem_block*) calloc(1, sizeof(struct mem_block));
+ newblock = calloc(1, sizeof(struct mem_block));
if (!newblock)
return NULL;
newblock->ofs = startofs;
@@ -127,7 +127,7 @@ SliceBlock(struct mem_block *p,
/* break right, also [p, newblock, p->next] */
if (size < p->size) {
- newblock = (struct mem_block*) calloc(1, sizeof(struct mem_block));
+ newblock = calloc(1, sizeof(struct mem_block));
if (!newblock)
return NULL;
newblock->ofs = startofs + size;
diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c
index 4c99199d9d1..a23bc998dd7 100644
--- a/src/mesa/main/pack.c
+++ b/src/mesa/main/pack.c
@@ -157,7 +157,7 @@ _mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels,
/* Alloc dest storage */
bytes = ((width + 7) / 8 * height);
- buffer = (GLubyte *) malloc( bytes );
+ buffer = malloc( bytes );
if (!buffer)
return NULL;
@@ -1270,7 +1270,7 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4],
dstFormat == GL_LUMINANCE_ALPHA ||
dstFormat == GL_LUMINANCE_INTEGER_EXT ||
dstFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT) {
- luminance = (GLfloat *) malloc(n * sizeof(GLfloat));
+ luminance = malloc(n * sizeof(GLfloat));
if (!luminance) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing");
return;
@@ -4361,7 +4361,7 @@ _mesa_unpack_color_span_ubyte(struct gl_context *ctx,
{
GLint dstComponents;
GLint rDst, gDst, bDst, aDst, lDst, iDst;
- GLfloat (*rgba)[4] = (GLfloat (*)[4]) malloc(4 * n * sizeof(GLfloat));
+ GLfloat (*rgba)[4] = malloc(4 * n * sizeof(GLfloat));
if (!rgba) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking");
@@ -4376,7 +4376,7 @@ _mesa_unpack_color_span_ubyte(struct gl_context *ctx,
* Extract image data and convert to RGBA floats
*/
if (srcFormat == GL_COLOR_INDEX) {
- GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint));
+ GLuint *indexes = malloc(n * sizeof(GLuint));
if (!indexes) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking");
@@ -4555,7 +4555,7 @@ _mesa_unpack_color_span_float( struct gl_context *ctx,
{
GLint dstComponents;
GLint rDst, gDst, bDst, aDst, lDst, iDst;
- GLfloat (*rgba)[4] = (GLfloat (*)[4]) malloc(4 * n * sizeof(GLfloat));
+ GLfloat (*rgba)[4] = malloc(4 * n * sizeof(GLfloat));
GLboolean intFormat = _mesa_is_enum_format_integer(srcFormat);
if (!rgba) {
@@ -4578,7 +4578,7 @@ _mesa_unpack_color_span_float( struct gl_context *ctx,
* Extract image data and convert to RGBA floats
*/
if (srcFormat == GL_COLOR_INDEX) {
- GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint));
+ GLuint *indexes = malloc(n * sizeof(GLuint));
if (!indexes) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking");
@@ -4691,7 +4691,7 @@ _mesa_unpack_color_span_uint(struct gl_context *ctx,
const GLvoid *source,
const struct gl_pixelstore_attrib *srcPacking)
{
- GLuint (*rgba)[4] = (GLuint (*)[4]) malloc(n * 4 * sizeof(GLfloat));
+ GLuint (*rgba)[4] = malloc(n * 4 * sizeof(GLfloat));
if (!rgba) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking");
@@ -4869,7 +4869,7 @@ _mesa_unpack_dudv_span_byte( struct gl_context *ctx,
GLint dstComponents;
GLbyte *dst = dest;
GLuint i;
- GLfloat (*rgba)[4] = (GLfloat (*)[4]) malloc(4 * n * sizeof(GLfloat));
+ GLfloat (*rgba)[4] = malloc(4 * n * sizeof(GLfloat));
if (!rgba) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking");
@@ -4956,7 +4956,7 @@ _mesa_unpack_index_span( struct gl_context *ctx, GLuint n,
/*
* general solution
*/
- GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint));
+ GLuint *indexes = malloc(n * sizeof(GLuint));
if (!indexes) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking");
@@ -5007,7 +5007,7 @@ _mesa_pack_index_span( struct gl_context *ctx, GLuint n,
const struct gl_pixelstore_attrib *dstPacking,
GLbitfield transferOps )
{
- GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint));
+ GLuint *indexes = malloc(n * sizeof(GLuint));
if (!indexes) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing");
@@ -5183,7 +5183,7 @@ _mesa_unpack_stencil_span( struct gl_context *ctx, GLuint n,
/*
* general solution
*/
- GLuint *indexes = (GLuint *) malloc(n * sizeof(GLuint));
+ GLuint *indexes = malloc(n * sizeof(GLuint));
if (!indexes) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "stencil unpacking");
@@ -5253,7 +5253,7 @@ _mesa_pack_stencil_span( struct gl_context *ctx, GLuint n,
GLenum dstType, GLvoid *dest, const GLubyte *source,
const struct gl_pixelstore_attrib *dstPacking )
{
- GLubyte *stencil = (GLubyte *) malloc(n * sizeof(GLubyte));
+ GLubyte *stencil = malloc(n * sizeof(GLubyte));
if (!stencil) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "stencil packing");
@@ -5475,7 +5475,7 @@ _mesa_unpack_depth_span( struct gl_context *ctx, GLuint n,
depthValues = (GLfloat *) dest;
}
else {
- depthTemp = (GLfloat *) malloc(n * sizeof(GLfloat));
+ depthTemp = malloc(n * sizeof(GLfloat));
if (!depthTemp) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking");
return;
@@ -5656,7 +5656,7 @@ _mesa_pack_depth_span( struct gl_context *ctx, GLuint n, GLvoid *dest,
GLenum dstType, const GLfloat *depthSpan,
const struct gl_pixelstore_attrib *dstPacking )
{
- GLfloat *depthCopy = (GLfloat *) malloc(n * sizeof(GLfloat));
+ GLfloat *depthCopy = malloc(n * sizeof(GLfloat));
if (!depthCopy) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing");
return;
@@ -5778,8 +5778,8 @@ _mesa_pack_depth_stencil_span(struct gl_context *ctx,GLuint n,
const GLubyte *stencilVals,
const struct gl_pixelstore_attrib *dstPacking)
{
- GLfloat *depthCopy = (GLfloat *) malloc(n * sizeof(GLfloat));
- GLubyte *stencilCopy = (GLubyte *) malloc(n * sizeof(GLubyte));
+ GLfloat *depthCopy = malloc(n * sizeof(GLfloat));
+ GLubyte *stencilCopy = malloc(n * sizeof(GLubyte));
GLuint i;
if (!depthCopy || !stencilCopy) {
@@ -5877,7 +5877,7 @@ _mesa_unpack_image( GLuint dimensions,
{
GLubyte *destBuffer
- = (GLubyte *) malloc(bytesPerRow * height * depth);
+ = malloc(bytesPerRow * height * depth);
GLubyte *dst;
GLint img, row;
if (!destBuffer)
diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
index 7dc758152ec..e10f921d289 100644
--- a/src/mesa/main/readpix.c
+++ b/src/mesa/main/readpix.c
@@ -143,7 +143,7 @@ read_depth_pixels( struct gl_context *ctx,
return;
}
- depthValues = (GLfloat *) malloc(width * sizeof(GLfloat));
+ depthValues = malloc(width * sizeof(GLfloat));
if (depthValues) {
/* General case (slower) */
@@ -191,7 +191,7 @@ read_stencil_pixels( struct gl_context *ctx,
return;
}
- stencil = (GLubyte *) malloc(width * sizeof(GLubyte));
+ stencil = malloc(width * sizeof(GLubyte));
if (stencil) {
/* process image row by row */
@@ -486,7 +486,7 @@ fast_read_depth_stencil_pixels_separate(struct gl_context *ctx,
return GL_TRUE; /* don't bother trying the slow path */
}
- stencilVals = (GLubyte *) malloc(width * sizeof(GLubyte));
+ stencilVals = malloc(width * sizeof(GLubyte));
if (stencilVals) {
for (j = 0; j < height; j++) {
@@ -557,8 +557,8 @@ slow_read_depth_stencil_pixels_separate(struct gl_context *ctx,
stencilStride = depthStride;
}
- stencilVals = (GLubyte *) malloc(width * sizeof(GLubyte));
- depthVals = (GLfloat *) malloc(width * sizeof(GLfloat));
+ stencilVals = malloc(width * sizeof(GLubyte));
+ depthVals = malloc(width * sizeof(GLfloat));
if (stencilVals && depthVals) {
for (j = 0; j < height; j++) {
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index d6acade3dab..badb96a305a 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -377,7 +377,7 @@ detach_shader(struct gl_context *ctx, GLuint program, GLuint shader)
_mesa_reference_shader(ctx, &shProg->Shaders[i], NULL);
/* alloc new, smaller array */
- newList = (struct gl_shader **)
+ newList =
malloc((n - 1) * sizeof(struct gl_shader *));
if (!newList) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glDetachShader");
@@ -1299,7 +1299,7 @@ read_shader(const char *fname)
return NULL;
}
- buffer = (char *) malloc(max);
+ buffer = malloc(max);
len = fread(buffer, 1, max, f);
buffer[len] = 0;
@@ -1336,7 +1336,7 @@ _mesa_ShaderSourceARB(GLhandleARB shaderObj, GLsizei count,
* This array holds offsets of where the appropriate string ends, thus the
* last element will be set to the total length of the source code.
*/
- offsets = (GLint *) malloc(count * sizeof(GLint));
+ offsets = malloc(count * sizeof(GLint));
if (offsets == NULL) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glShaderSourceARB");
return;
@@ -1363,7 +1363,7 @@ _mesa_ShaderSourceARB(GLhandleARB shaderObj, GLsizei count,
* valgrind warnings in the parser/grammer code.
*/
totalLength = offsets[count - 1] + 2;
- source = (GLcharARB *) malloc(totalLength * sizeof(GLcharARB));
+ source = malloc(totalLength * sizeof(GLcharARB));
if (source == NULL) {
free((GLvoid *) offsets);
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glShaderSourceARB");
diff --git a/src/mesa/main/texcompress_cpal.c b/src/mesa/main/texcompress_cpal.c
index 2398ded69f4..48665212d98 100644
--- a/src/mesa/main/texcompress_cpal.c
+++ b/src/mesa/main/texcompress_cpal.c
@@ -208,7 +208,7 @@ _mesa_cpal_compressed_teximage2d(GLenum target, GLint level,
/* allocate and fill dest image buffer */
if (palette) {
- image = (GLubyte *) malloc(num_texels * info->size);
+ image = malloc(num_texels * info->size);
paletted_to_color(info, palette, indices, num_texels, image);
}
diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index ee43d0d89b2..a3720699df5 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -80,7 +80,7 @@ get_tex_depth(struct gl_context *ctx, GLuint dimensions,
const GLint height = texImage->Height;
const GLint depth = texImage->Depth;
GLint img, row;
- GLfloat *depthRow = (GLfloat *) malloc(width * sizeof(GLfloat));
+ GLfloat *depthRow = malloc(width * sizeof(GLfloat));
if (!depthRow) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage");
@@ -236,7 +236,7 @@ get_tex_rgba_compressed(struct gl_context *ctx, GLuint dimensions,
GLuint row;
/* Decompress into temp float buffer, then pack into user buffer */
- tempImage = (GLfloat *) malloc(width * height * depth
+ tempImage = malloc(width * height * depth
* 4 * sizeof(GLfloat));
if (!tempImage) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage()");
@@ -310,7 +310,7 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions,
GLboolean tex_is_uint = _mesa_is_format_unsigned(texImage->TexFormat);
/* Allocate buffer for one row of texels */
- rgba = (GLfloat (*)[4]) malloc(4 * width * sizeof(GLfloat));
+ rgba = malloc(4 * width * sizeof(GLfloat));
rgba_uint = (GLuint (*)[4]) rgba;
if (!rgba) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage()");
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 18429f58163..2d055808ead 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -354,7 +354,7 @@ _mesa_make_temp_float_image(struct gl_context *ctx, GLuint dims,
textureBaseFormat == GL_INTENSITY ||
textureBaseFormat == GL_DEPTH_COMPONENT);
- tempImage = (GLfloat *) malloc(srcWidth * srcHeight * srcDepth
+ tempImage = malloc(srcWidth * srcHeight * srcDepth
* components * sizeof(GLfloat));
if (!tempImage)
return NULL;
@@ -392,7 +392,7 @@ _mesa_make_temp_float_image(struct gl_context *ctx, GLuint dims,
*/
ASSERT(texComponents >= logComponents);
- newImage = (GLfloat *) malloc(srcWidth * srcHeight * srcDepth
+ newImage = malloc(srcWidth * srcHeight * srcDepth
* texComponents * sizeof(GLfloat));
if (!newImage) {
free(tempImage);
@@ -463,7 +463,7 @@ make_temp_uint_image(struct gl_context *ctx, GLuint dims,
textureBaseFormat == GL_INTENSITY ||
textureBaseFormat == GL_ALPHA);
- tempImage = (GLuint *) malloc(srcWidth * srcHeight * srcDepth
+ tempImage = malloc(srcWidth * srcHeight * srcDepth
* components * sizeof(GLuint));
if (!tempImage)
return NULL;
@@ -501,7 +501,7 @@ make_temp_uint_image(struct gl_context *ctx, GLuint dims,
*/
ASSERT(texComponents >= logComponents);
- newImage = (GLuint *) malloc(srcWidth * srcHeight * srcDepth
+ newImage = malloc(srcWidth * srcHeight * srcDepth
* texComponents * sizeof(GLuint));
if (!newImage) {
free(tempImage);
@@ -591,7 +591,7 @@ _mesa_make_temp_ubyte_image(struct gl_context *ctx, GLuint dims,
textureBaseFormat == GL_INTENSITY);
/* unpack and transfer the source image */
- tempImage = (GLubyte *) malloc(srcWidth * srcHeight * srcDepth
+ tempImage = malloc(srcWidth * srcHeight * srcDepth
* components * sizeof(GLubyte));
if (!tempImage) {
return NULL;
@@ -632,7 +632,7 @@ _mesa_make_temp_ubyte_image(struct gl_context *ctx, GLuint dims,
*/
ASSERT(texComponents >= logComponents);
- newImage = (GLubyte *) malloc(srcWidth * srcHeight * srcDepth
+ newImage = malloc(srcWidth * srcHeight * srcDepth
* texComponents * sizeof(GLubyte));
if (!newImage) {
free(tempImage);
@@ -2393,7 +2393,7 @@ _mesa_texstore_dudv8(TEXSTORE_PARAMS)
GLbyte *tempImage, *dst, *src;
GLint row;
- tempImage = (GLbyte *) malloc(srcWidth * srcHeight * srcDepth
+ tempImage = malloc(srcWidth * srcHeight * srcDepth
* components * sizeof(GLbyte));
if (!tempImage)
return GL_FALSE;
@@ -2797,8 +2797,8 @@ _mesa_texstore_z24_s8(TEXSTORE_PARAMS)
}
else if (srcFormat == GL_DEPTH_COMPONENT ||
srcFormat == GL_STENCIL_INDEX) {
- GLuint *depth = (GLuint *) malloc(srcWidth * sizeof(GLuint));
- GLubyte *stencil = (GLubyte *) malloc(srcWidth * sizeof(GLubyte));
+ GLuint *depth = malloc(srcWidth * sizeof(GLuint));
+ GLubyte *stencil = malloc(srcWidth * sizeof(GLubyte));
if (!depth || !stencil) {
free(depth);
@@ -2880,8 +2880,8 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS)
ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT ||
srcType == GL_UNSIGNED_INT_24_8_EXT);
- depth = (GLuint *) malloc(srcWidth * sizeof(GLuint));
- stencil = (GLubyte *) malloc(srcWidth * sizeof(GLubyte));
+ depth = malloc(srcWidth * sizeof(GLuint));
+ stencil = malloc(srcWidth * sizeof(GLubyte));
if (!depth || !stencil) {
free(depth);
@@ -2967,7 +2967,7 @@ _mesa_texstore_s8(TEXSTORE_PARAMS)
const GLint srcRowStride
= _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
GLint img, row;
- GLubyte *stencil = (GLubyte *) malloc(srcWidth * sizeof(GLubyte));
+ GLubyte *stencil = malloc(srcWidth * sizeof(GLubyte));
if (!stencil)
return GL_FALSE;
diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c
index 7679b4b0853..26345b10029 100644
--- a/src/mesa/main/transformfeedback.c
+++ b/src/mesa/main/transformfeedback.c
@@ -643,7 +643,7 @@ _mesa_TransformFeedbackVaryings(GLuint program, GLsizei count,
/* allocate new memory for varying names */
shProg->TransformFeedback.VaryingNames =
- (GLchar **) malloc(count * sizeof(GLchar *));
+ malloc(count * sizeof(GLchar *));
if (!shProg->TransformFeedback.VaryingNames) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTransformFeedbackVaryings()");
diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index f43d0fbee07..04cf0a2b0d1 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -99,7 +99,7 @@ _mesa_uniform_attach_driver_storage(struct gl_uniform_storage *uni,
enum gl_uniform_driver_format format,
void *data)
{
- uni->driver_storage = (struct gl_uniform_driver_storage*)
+ uni->driver_storage =
realloc(uni->driver_storage,
sizeof(struct gl_uniform_driver_storage)
* (uni->num_driver_storage + 1));
diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c
index f22118a0d1f..bc7b1fa0e00 100644
--- a/src/mesa/main/version.c
+++ b/src/mesa/main/version.c
@@ -224,7 +224,7 @@ compute_version(struct gl_context *ctx)
override_version(ctx);
- ctx->VersionString = (char *) malloc(max);
+ ctx->VersionString = malloc(max);
if (ctx->VersionString) {
_mesa_snprintf(ctx->VersionString, max,
"%u.%u Mesa " MESA_VERSION_STRING
@@ -256,7 +256,7 @@ compute_version_es1(struct gl_context *ctx)
_mesa_problem(ctx, "Incomplete OpenGL ES 1.0 support.");
}
- ctx->VersionString = (char *) malloc(max);
+ ctx->VersionString = malloc(max);
if (ctx->VersionString) {
_mesa_snprintf(ctx->VersionString, max,
"OpenGL ES-CM 1.%d Mesa " MESA_VERSION_STRING
@@ -289,7 +289,7 @@ compute_version_es2(struct gl_context *ctx)
_mesa_problem(ctx, "Incomplete OpenGL ES 2.0 support.");
}
- ctx->VersionString = (char *) malloc(max);
+ ctx->VersionString = malloc(max);
if (ctx->VersionString) {
_mesa_snprintf(ctx->VersionString, max,
"OpenGL ES 2.0 Mesa " MESA_VERSION_STRING
diff --git a/src/mesa/main/vsnprintf.c b/src/mesa/main/vsnprintf.c
index ab6c740d772..3bbc0a9e2e9 100644
--- a/src/mesa/main/vsnprintf.c
+++ b/src/mesa/main/vsnprintf.c
@@ -67,7 +67,7 @@ msetup(str, n)
return NULL;
if (pgsize == 0)
pgsize = getpagesize();
- curobj = (char *)malloc(n + EXTRABYTES + pgsize * 2);
+ curobj = malloc(n + EXTRABYTES + pgsize * 2);
if (curobj == NULL)
return NULL;
e = curobj + n + EXTRABYTES;