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) )
This commit is contained in:
@@ -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");
|
||||
|
Reference in New Issue
Block a user