aboutsummaryrefslogtreecommitdiff
path: root/mesalib
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-09-06 08:49:13 +0200
committermarha <marha@users.sourceforge.net>2012-09-06 08:49:13 +0200
commitccc8a492607df715b08d27c6bb3b9d13b1ff48a2 (patch)
tree4311d252acd49786ceed60cb55343af0a9294a2f /mesalib
parenta4d007b9b60f2fc7c8de46533e2f47ecb24f3c9c (diff)
parentaa10a08696cae93799fcddae3f0245ceee905e01 (diff)
downloadvcxsrv-ccc8a492607df715b08d27c6bb3b9d13b1ff48a2.tar.gz
vcxsrv-ccc8a492607df715b08d27c6bb3b9d13b1ff48a2.tar.bz2
vcxsrv-ccc8a492607df715b08d27c6bb3b9d13b1ff48a2.zip
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'mesalib')
-rw-r--r--mesalib/configure.ac1
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_draw_quad.c3
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format.c8
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_snprintf.c2
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_string.h4
-rw-r--r--mesalib/src/mapi/glapi/gen/glX_proto_send.py6
-rw-r--r--mesalib/src/mapi/glapi/gen/gl_x86-64_asm.py2
-rw-r--r--mesalib/src/mapi/glapi/gen/gl_x86_asm.py2
-rw-r--r--mesalib/src/mapi/glapi/glapi_dispatch.c2
-rw-r--r--mesalib/src/mapi/glapi/glapi_getproc.c2
-rw-r--r--mesalib/src/mapi/mapi/u_current.c2
-rw-r--r--mesalib/src/mapi/mapi/u_thread.h4
-rw-r--r--mesalib/src/mesa/drivers/common/meta.c4
-rw-r--r--mesalib/src/mesa/drivers/dri/common/xmlconfig.c9
-rw-r--r--mesalib/src/mesa/drivers/windows/gdi/wgl.c2
-rw-r--r--mesalib/src/mesa/drivers/windows/gdi/wmesa.c2
-rw-r--r--mesalib/src/mesa/main/accum.c6
-rw-r--r--mesalib/src/mesa/main/atifragshader.c14
-rw-r--r--mesalib/src/mesa/main/attrib.c2
-rw-r--r--mesalib/src/mesa/main/bufferobj.c3
-rw-r--r--mesalib/src/mesa/main/compiler.h17
-rw-r--r--mesalib/src/mesa/main/context.c10
-rw-r--r--mesalib/src/mesa/main/cpuinfo.c2
-rw-r--r--mesalib/src/mesa/main/debug.c18
-rw-r--r--mesalib/src/mesa/main/dlist.c14
-rw-r--r--mesalib/src/mesa/main/eval.c16
-rw-r--r--mesalib/src/mesa/main/extensions.c2
-rw-r--r--mesalib/src/mesa/main/format_unpack.c2
-rw-r--r--mesalib/src/mesa/main/get.c2
-rw-r--r--mesalib/src/mesa/main/imports.c11
-rw-r--r--mesalib/src/mesa/main/matrix.c2
-rw-r--r--mesalib/src/mesa/main/mipmap.c8
-rw-r--r--mesalib/src/mesa/main/mm.c8
-rw-r--r--mesalib/src/mesa/main/pack.c34
-rw-r--r--mesalib/src/mesa/main/readpix.c10
-rw-r--r--mesalib/src/mesa/main/shaderapi.c12
-rw-r--r--mesalib/src/mesa/main/shaderobj.c9
-rw-r--r--mesalib/src/mesa/main/texcompress_cpal.c5
-rw-r--r--mesalib/src/mesa/main/texcompress_fxt1.c4
-rw-r--r--mesalib/src/mesa/main/texgetimage.c6
-rw-r--r--mesalib/src/mesa/main/teximage.c36
-rw-r--r--mesalib/src/mesa/main/texstore.c24
-rw-r--r--mesalib/src/mesa/main/transformfeedback.c2
-rw-r--r--mesalib/src/mesa/main/uniforms.c2
-rw-r--r--mesalib/src/mesa/main/version.c6
-rw-r--r--mesalib/src/mesa/main/vsnprintf.c2
-rw-r--r--mesalib/src/mesa/math/m_debug_norm.c2
-rw-r--r--mesalib/src/mesa/math/m_debug_xform.c2
-rw-r--r--mesalib/src/mesa/math/m_matrix.c4
-rw-r--r--mesalib/src/mesa/math/m_trans_tmp.h16
-rw-r--r--mesalib/src/mesa/math/m_translate.c34
-rw-r--r--mesalib/src/mesa/math/m_translate.h18
-rw-r--r--mesalib/src/mesa/math/m_xform.h16
-rw-r--r--mesalib/src/mesa/program/arbprogparse.c12
-rw-r--r--mesalib/src/mesa/program/nvfragparse.c12
-rw-r--r--mesalib/src/mesa/program/nvvertparse.c12
-rw-r--r--mesalib/src/mesa/program/prog_cache.c4
-rw-r--r--mesalib/src/mesa/program/prog_instruction.c8
-rw-r--r--mesalib/src/mesa/program/prog_optimize.c6
-rw-r--r--mesalib/src/mesa/program/prog_parameter.c3
-rw-r--r--mesalib/src/mesa/program/program.c5
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_drawpixels.c8
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_texture.c9
-rw-r--r--mesalib/src/mesa/swrast/s_context.c15
-rw-r--r--mesalib/src/mesa/swrast/s_copypix.c10
-rw-r--r--mesalib/src/mesa/swrast/s_depth.c4
-rw-r--r--mesalib/src/mesa/swrast/s_drawpix.c8
-rw-r--r--mesalib/src/mesa/swrast/s_renderbuffer.c12
-rw-r--r--mesalib/src/mesa/swrast/s_texcombine.c8
-rw-r--r--mesalib/src/mesa/swrast/s_texfilter.c2
-rw-r--r--mesalib/src/mesa/swrast/s_texture.c8
-rw-r--r--mesalib/src/mesa/swrast/s_zoom.c4
-rw-r--r--mesalib/src/mesa/swrast_setup/ss_context.c2
-rw-r--r--mesalib/src/mesa/tnl/t_context.c2
-rw-r--r--mesalib/src/mesa/tnl/t_vb_program.c2
-rw-r--r--mesalib/src/mesa/tnl/t_vb_texgen.c8
-rw-r--r--mesalib/src/mesa/tnl/t_vb_vertex.c2
-rw-r--r--mesalib/src/mesa/tnl/t_vertex.c4
-rw-r--r--mesalib/src/mesa/vbo/vbo_exec_api.c2
-rw-r--r--mesalib/src/mesa/vbo/vbo_primitive_restart.c6
-rw-r--r--mesalib/src/mesa/vbo/vbo_rebase.c10
-rw-r--r--mesalib/src/mesa/vbo/vbo_save_api.c6
-rw-r--r--mesalib/src/mesa/x86/common_x86.c6
-rw-r--r--mesalib/src/mesa/x86/norm_args.h6
84 files changed, 288 insertions, 354 deletions
diff --git a/mesalib/configure.ac b/mesalib/configure.ac
index 82fe2251b..6e67ec039 100644
--- a/mesalib/configure.ac
+++ b/mesalib/configure.ac
@@ -908,7 +908,6 @@ AC_SUBST([GLAPI_LIB_DEPS])
DRI_LIB_DEPS="\$(top_builddir)/src/mesa/libdricore/libdricore${VERSION}.la"
-GALLIUM_DRI_LIB_DEPS="\$(TOP)/\$(LIB_DIR)/libdricore${VERSION}.so"
AC_SUBST([HAVE_XF86VIDMODE])
diff --git a/mesalib/src/gallium/auxiliary/util/u_draw_quad.c b/mesalib/src/gallium/auxiliary/util/u_draw_quad.c
index 469c87498..81c4f107e 100644
--- a/mesalib/src/gallium/auxiliary/util/u_draw_quad.c
+++ b/mesalib/src/gallium/auxiliary/util/u_draw_quad.c
@@ -151,6 +151,5 @@ out:
if (vbuf)
pipe_resource_reference(&vbuf, NULL);
- if (v)
- FREE(v);
+ FREE(v);
}
diff --git a/mesalib/src/gallium/auxiliary/util/u_format.c b/mesalib/src/gallium/auxiliary/util/u_format.c
index 6f4529835..a41c468a9 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format.c
+++ b/mesalib/src/gallium/auxiliary/util/u_format.c
@@ -618,13 +618,9 @@ util_format_translate(enum pipe_format dst_format,
src_row += src_step;
}
- if (tmp_s) {
- FREE(tmp_s);
- }
+ FREE(tmp_s);
- if (tmp_z) {
- FREE(tmp_z);
- }
+ FREE(tmp_z);
return;
}
diff --git a/mesalib/src/gallium/auxiliary/util/u_snprintf.c b/mesalib/src/gallium/auxiliary/util/u_snprintf.c
index f0d53b3ce..e16f103e3 100644
--- a/mesalib/src/gallium/auxiliary/util/u_snprintf.c
+++ b/mesalib/src/gallium/auxiliary/util/u_snprintf.c
@@ -167,7 +167,7 @@
#if HAVE_CONFIG_H
#include <config.h>
#else
-#ifdef WIN32
+#ifdef _WIN32
#define vsnprintf util_vsnprintf
#define snprintf util_snprintf
#define HAVE_VSNPRINTF 0
diff --git a/mesalib/src/gallium/auxiliary/util/u_string.h b/mesalib/src/gallium/auxiliary/util/u_string.h
index ed15981f1..15630ad07 100644
--- a/mesalib/src/gallium/auxiliary/util/u_string.h
+++ b/mesalib/src/gallium/auxiliary/util/u_string.h
@@ -35,7 +35,7 @@
#ifndef U_STRING_H_
#define U_STRING_H_
-#if !defined(WIN32) && !defined(XF86_LIBC_H)
+#if !defined(_WIN32) && !defined(XF86_LIBC_H)
#include <stdio.h>
#endif
#include <stddef.h>
@@ -64,7 +64,7 @@ util_strchrnul(const char *s, char c)
#endif
-#ifdef WIN32
+#ifdef _WIN32
int util_vsnprintf(char *, size_t, const char *, va_list);
int util_snprintf(char *str, size_t size, const char *format, ...);
diff --git a/mesalib/src/mapi/glapi/gen/glX_proto_send.py b/mesalib/src/mapi/glapi/gen/glX_proto_send.py
index c53359240..d42f661ea 100644
--- a/mesalib/src/mapi/glapi/gen/glX_proto_send.py
+++ b/mesalib/src/mapi/glapi/gen/glX_proto_send.py
@@ -239,7 +239,7 @@ __glXReadPixelReply( Display *dpy, struct glx_context * gc, unsigned max_dim,
size = reply.length * 4;
if (size != 0) {
- void * buf = Xmalloc( size );
+ void * buf = malloc( size );
if ( buf == NULL ) {
_XEatData(dpy, size);
@@ -255,7 +255,7 @@ __glXReadPixelReply( Display *dpy, struct glx_context * gc, unsigned max_dim,
__glEmptyImage(gc, 3, width, height, depth, format, type,
buf, dest);
- Xfree(buf);
+ free(buf);
}
}
}
@@ -970,7 +970,7 @@ struct _glapi_table * __glXNewIndirectAPI( void )
int o;
entries = _glapi_get_dispatch_table_size();
- table = (_glapi_proc *) Xmalloc(entries * sizeof(_glapi_proc));
+ table = malloc(entries * sizeof(_glapi_proc));
/* first, set all entries to point to no-op functions */
for (i = 0; i < entries; i++) {
diff --git a/mesalib/src/mapi/glapi/gen/gl_x86-64_asm.py b/mesalib/src/mapi/glapi/gen/gl_x86-64_asm.py
index ef759bf7b..3ef5e08a9 100644
--- a/mesalib/src/mapi/glapi/gen/gl_x86-64_asm.py
+++ b/mesalib/src/mapi/glapi/gen/gl_x86-64_asm.py
@@ -138,7 +138,7 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print '# define GL_PREFIX(n) GLNAME(CONCAT(gl,n))'
print '# endif'
print ''
- print '#if defined(PTHREADS) || defined(WIN32)'
+ print '#if defined(PTHREADS) || defined(_WIN32)'
print '# define THREADS'
print '#endif'
print ''
diff --git a/mesalib/src/mapi/glapi/gen/gl_x86_asm.py b/mesalib/src/mapi/glapi/gen/gl_x86_asm.py
index b43b65dd8..095edcdc0 100644
--- a/mesalib/src/mapi/glapi/gen/gl_x86_asm.py
+++ b/mesalib/src/mapi/glapi/gen/gl_x86_asm.py
@@ -78,7 +78,7 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print '#define GLOBL_FN(x) GLOBL x'
print '#endif'
print ''
- print '#if defined(PTHREADS) || defined(WIN32)'
+ print '#if defined(PTHREADS) || defined(_WIN32)'
print '# define THREADS'
print '#endif'
print ''
diff --git a/mesalib/src/mapi/glapi/glapi_dispatch.c b/mesalib/src/mapi/glapi/glapi_dispatch.c
index 989f4a3fc..be65ebedd 100644
--- a/mesalib/src/mapi/glapi/glapi_dispatch.c
+++ b/mesalib/src/mapi/glapi/glapi_dispatch.c
@@ -43,7 +43,7 @@
#if !(defined(USE_X86_ASM) || defined(USE_X86_64_ASM) || defined(USE_SPARC_ASM))
-#if defined(WIN32)
+#if defined(_WIN32)
#define KEYWORD1 GLAPI
#else
#define KEYWORD1 PUBLIC
diff --git a/mesalib/src/mapi/glapi/glapi_getproc.c b/mesalib/src/mapi/glapi/glapi_getproc.c
index 3dde59680..231db46c3 100644
--- a/mesalib/src/mapi/glapi/glapi_getproc.c
+++ b/mesalib/src/mapi/glapi/glapi_getproc.c
@@ -244,7 +244,7 @@ static char *
str_dup(const char *str)
{
char *copy;
- copy = (char*) malloc(strlen(str) + 1);
+ copy = malloc(strlen(str) + 1);
if (!copy)
return NULL;
strcpy(copy, str);
diff --git a/mesalib/src/mapi/mapi/u_current.c b/mesalib/src/mapi/mapi/u_current.c
index 21a07abba..d902375f8 100644
--- a/mesalib/src/mapi/mapi/u_current.c
+++ b/mesalib/src/mapi/mapi/u_current.c
@@ -125,7 +125,7 @@ static int ThreadSafe;
void
u_current_destroy(void)
{
-#if defined(THREADS) && defined(WIN32)
+#if defined(THREADS) && defined(_WIN32)
u_tsd_destroy(&u_current_table_tsd);
u_tsd_destroy(&u_current_user_tsd);
#endif
diff --git a/mesalib/src/mapi/mapi/u_thread.h b/mesalib/src/mapi/mapi/u_thread.h
index ffe17b207..e53f872c9 100644
--- a/mesalib/src/mapi/mapi/u_thread.h
+++ b/mesalib/src/mapi/mapi/u_thread.h
@@ -153,7 +153,7 @@ u_tsd_set(struct u_tsd *tsd, void *ptr)
* IMPORTANT: Link with multithreaded runtime library when THREADS are
* used!
*/
-#ifdef WIN32
+#ifdef _WIN32
struct u_tsd {
DWORD key;
@@ -225,7 +225,7 @@ u_tsd_set(struct u_tsd *tsd, void *ptr)
}
}
-#endif /* WIN32 */
+#endif /* _WIN32 */
/*
diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c
index 36672a71d..7e81e5ee1 100644
--- a/mesalib/src/mesa/drivers/common/meta.c
+++ b/mesalib/src/mesa/drivers/common/meta.c
@@ -1660,7 +1660,7 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx,
}
if (mask & GL_DEPTH_BUFFER_BIT) {
- GLuint *tmp = (GLuint *) malloc(srcW * srcH * sizeof(GLuint));
+ GLuint *tmp = malloc(srcW * srcH * sizeof(GLuint));
if (tmp) {
if (!blit->DepthFP)
init_blit_depth_pixels(ctx);
@@ -2712,7 +2712,7 @@ _mesa_meta_Bitmap(struct gl_context *ctx,
return;
}
- bitmap8 = (GLubyte *) malloc(width * height);
+ bitmap8 = malloc(width * height);
if (bitmap8) {
memset(bitmap8, bg, width * height);
_mesa_expand_bitmap(width, height, &unpackSave, bitmap1,
diff --git a/mesalib/src/mesa/drivers/dri/common/xmlconfig.c b/mesalib/src/mesa/drivers/dri/common/xmlconfig.c
index 929748400..72483a42a 100644
--- a/mesalib/src/mesa/drivers/dri/common/xmlconfig.c
+++ b/mesalib/src/mesa/drivers/dri/common/xmlconfig.c
@@ -989,8 +989,7 @@ void driParseConfigFiles (driOptionCache *cache, const driOptionCache *info,
XML_ParserFree (p);
}
- if (filenames[1])
- free(filenames[1]);
+ free(filenames[1]);
}
void driDestroyOptionInfo (driOptionCache *info) {
@@ -1000,8 +999,7 @@ void driDestroyOptionInfo (driOptionCache *info) {
for (i = 0; i < size; ++i) {
if (info->info[i].name) {
free(info->info[i].name);
- if (info->info[i].ranges)
- free(info->info[i].ranges);
+ free(info->info[i].ranges);
}
}
free(info->info);
@@ -1009,8 +1007,7 @@ void driDestroyOptionInfo (driOptionCache *info) {
}
void driDestroyOptionCache (driOptionCache *cache) {
- if (cache->values)
- free(cache->values);
+ free(cache->values);
}
GLboolean driCheckOption (const driOptionCache *cache, const char *name,
diff --git a/mesalib/src/mesa/drivers/windows/gdi/wgl.c b/mesalib/src/mesa/drivers/windows/gdi/wgl.c
index d99473bb3..3458cc9f3 100644
--- a/mesalib/src/mesa/drivers/windows/gdi/wgl.c
+++ b/mesalib/src/mesa/drivers/windows/gdi/wgl.c
@@ -382,7 +382,7 @@ static BOOL wglUseFontBitmaps_FX(HDC fontDevice, DWORD firstChar,
VERIFY(GetTextMetrics(fontDevice, &metric));
- dibInfo = (BITMAPINFO *) calloc(sizeof(BITMAPINFO) + sizeof(RGBQUAD), 1);
+ dibInfo = calloc(sizeof(BITMAPINFO) + sizeof(RGBQUAD), 1);
dibInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
dibInfo->bmiHeader.biPlanes = 1;
dibInfo->bmiHeader.biBitCount = 1;
diff --git a/mesalib/src/mesa/drivers/windows/gdi/wmesa.c b/mesalib/src/mesa/drivers/windows/gdi/wmesa.c
index 93da05fe7..c61020273 100644
--- a/mesalib/src/mesa/drivers/windows/gdi/wmesa.c
+++ b/mesalib/src/mesa/drivers/windows/gdi/wmesa.c
@@ -35,7 +35,7 @@ static WMesaFramebuffer
wmesa_new_framebuffer(HDC hdc, struct gl_config *visual)
{
WMesaFramebuffer pwfb
- = (WMesaFramebuffer) malloc(sizeof(struct wmesa_framebuffer));
+ = malloc(sizeof(struct wmesa_framebuffer));
if (pwfb) {
_mesa_initialize_window_framebuffer(&pwfb->Base, visual);
pwfb->hDC = hdc;
diff --git a/mesalib/src/mesa/main/accum.c b/mesalib/src/mesa/main/accum.c
index df6f219bf..16c26168a 100644
--- a/mesalib/src/mesa/main/accum.c
+++ b/mesalib/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/mesalib/src/mesa/main/atifragshader.c b/mesalib/src/mesa/main/atifragshader.c
index c74c999f8..63608a33f 100644
--- a/mesalib/src/mesa/main/atifragshader.c
+++ b/mesalib/src/mesa/main/atifragshader.c
@@ -83,10 +83,8 @@ _mesa_delete_ati_fragment_shader(struct gl_context *ctx, struct ati_fragment_sha
{
GLuint i;
for (i = 0; i < MAX_NUM_PASSES_ATI; i++) {
- if (s->Instructions[i])
- free(s->Instructions[i]);
- if (s->SetupInst[i])
- free(s->SetupInst[i]);
+ free(s->Instructions[i]);
+ free(s->SetupInst[i]);
}
free(s);
}
@@ -342,21 +340,17 @@ _mesa_BeginFragmentShaderATI(void)
(or, could use the same mem but would need to reinitialize) */
/* no idea if it's allowed to redefine a shader */
for (i = 0; i < MAX_NUM_PASSES_ATI; i++) {
- if (ctx->ATIFragmentShader.Current->Instructions[i])
- free(ctx->ATIFragmentShader.Current->Instructions[i]);
- if (ctx->ATIFragmentShader.Current->SetupInst[i])
- free(ctx->ATIFragmentShader.Current->SetupInst[i]);
+ free(ctx->ATIFragmentShader.Current->Instructions[i]);
+ free(ctx->ATIFragmentShader.Current->SetupInst[i]);
}
/* malloc the instructions here - not sure if the best place but its
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/mesalib/src/mesa/main/attrib.c b/mesalib/src/mesa/main/attrib.c
index b3d10d31e..806cf09d8 100644
--- a/mesalib/src/mesa/main/attrib.c
+++ b/mesalib/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/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c
index 01bc3c216..f8fd32922 100644
--- a/mesalib/src/mesa/main/bufferobj.c
+++ b/mesalib/src/mesa/main/bufferobj.c
@@ -264,8 +264,7 @@ _mesa_delete_buffer_object(struct gl_context *ctx,
{
(void) ctx;
- if (bufObj->Data)
- free(bufObj->Data);
+ free(bufObj->Data);
/* assign strange values here to help w/ debugging */
bufObj->RefCount = -1000;
diff --git a/mesalib/src/mesa/main/compiler.h b/mesalib/src/mesa/main/compiler.h
index 94484d8f3..a8cddaf8f 100644
--- a/mesalib/src/mesa/main/compiler.h
+++ b/mesalib/src/mesa/main/compiler.h
@@ -90,7 +90,7 @@ extern "C" {
/**
* Disable assorted warnings
*/
-#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP)
+#if !defined(OPENSTEP) && (defined(_WIN32) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP)
# if !defined(__GNUC__) /* mingw environment */
# pragma warning( disable : 4068 ) /* unknown pragma */
# pragma warning( disable : 4710 ) /* function 'foo' not inlined */
@@ -161,17 +161,6 @@ extern "C" {
/**
- * Some compilers don't like some of Mesa's const usage. In those places use
- * CONST instead of const. Pass -DNO_CONST to compilers where this matters.
- */
-#ifdef NO_CONST
-# define CONST
-#else
-# define CONST const
-#endif
-
-
-/**
* __builtin_expect macros
*/
#if !defined(__GNUC__)
@@ -257,7 +246,7 @@ static INLINE GLuint CPU_TO_LE32(GLuint x)
-#if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP)
+#if !defined(CAPI) && defined(_WIN32) && !defined(BUILD_FOR_SNAP)
#define CAPI _cdecl
#endif
@@ -267,7 +256,7 @@ static INLINE GLuint CPU_TO_LE32(GLuint x)
* than GNU C
*/
#ifndef _ASMAPI
-#if defined(WIN32) && !defined(BUILD_FOR_SNAP)/* was: !defined( __GNUC__ ) && !defined( VMS ) && !defined( __INTEL_COMPILER )*/
+#if defined(_WIN32) && !defined(BUILD_FOR_SNAP)/* was: !defined( __GNUC__ ) && !defined( VMS ) && !defined( __INTEL_COMPILER )*/
#define _ASMAPI __cdecl
#else
#define _ASMAPI
diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c
index feddbaa7e..6b28690ec 100644
--- a/mesalib/src/mesa/main/context.c
+++ b/mesalib/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;
@@ -1158,11 +1158,9 @@ _mesa_free_context_data( struct gl_context *ctx )
_mesa_free_errors_data(ctx);
- if (ctx->Extensions.String)
- free((void *) ctx->Extensions.String);
+ free((void *)ctx->Extensions.String);
- if (ctx->VersionString)
- free(ctx->VersionString);
+ free(ctx->VersionString);
/* unbind the context if it's currently bound */
if (ctx == _mesa_get_current_context()) {
diff --git a/mesalib/src/mesa/main/cpuinfo.c b/mesalib/src/mesa/main/cpuinfo.c
index 0d7971bcc..41505f637 100644
--- a/mesalib/src/mesa/main/cpuinfo.c
+++ b/mesalib/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/mesalib/src/mesa/main/debug.c b/mesalib/src/mesa/main/debug.c
index 62b8e00c1..aee8ae2dc 100644
--- a/mesalib/src/mesa/main/debug.c
+++ b/mesalib/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/mesalib/src/mesa/main/dlist.c b/mesalib/src/mesa/main/dlist.c
index 5a813e98a..40e693364 100644
--- a/mesalib/src/mesa/main/dlist.c
+++ b/mesalib/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/mesalib/src/mesa/main/eval.c b/mesalib/src/mesa/main/eval.c
index 487c4ce04..ca1b33bd2 100644
--- a/mesalib/src/mesa/main/eval.c
+++ b/mesalib/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/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c
index 7e116bdd1..36e1fcf62 100644
--- a/mesalib/src/mesa/main/extensions.c
+++ b/mesalib/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/mesalib/src/mesa/main/format_unpack.c b/mesalib/src/mesa/main/format_unpack.c
index bd218520f..7b46dfc79 100644
--- a/mesalib/src/mesa/main/format_unpack.c
+++ b/mesalib/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/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c
index fe1035be8..24d2a18fe 100644
--- a/mesalib/src/mesa/main/get.c
+++ b/mesalib/src/mesa/main/get.c
@@ -61,8 +61,6 @@
* is about as concise as the specification in the old python script.
*/
-#undef CONST
-
#define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE )
#define FLOAT_TO_FIXED(F) ( ((F) * 65536.0f > INT_MAX) ? INT_MAX : \
((F) * 65536.0f < INT_MIN) ? INT_MIN : \
diff --git a/mesalib/src/mesa/main/imports.c b/mesalib/src/mesa/main/imports.c
index 0d6b56a51..934a2d05f 100644
--- a/mesalib/src/mesa/main/imports.c
+++ b/mesalib/src/mesa/main/imports.c
@@ -57,7 +57,7 @@
#endif
-#ifdef WIN32
+#ifdef _WIN32
#define vsnprintf _vsnprintf
#elif defined(__IBMC__) || defined(__IBMCPP__) || ( defined(__VMS) && __CRTL_VER < 70312000 )
extern int vsnprintf(char *str, size_t count, const char *fmt, va_list arg);
@@ -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;
@@ -218,8 +218,7 @@ _mesa_realloc(void *oldBuffer, size_t oldSize, size_t newSize)
void *newBuffer = malloc(newSize);
if (newBuffer && oldBuffer && copySize > 0)
memcpy(newBuffer, oldBuffer, copySize);
- if (oldBuffer)
- free(oldBuffer);
+ free(oldBuffer);
return newBuffer;
}
@@ -527,7 +526,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/mesalib/src/mesa/main/matrix.c b/mesalib/src/mesa/main/matrix.c
index a6193071d..5c3569c16 100644
--- a/mesalib/src/mesa/main/matrix.c
+++ b/mesalib/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/mesalib/src/mesa/main/mipmap.c b/mesalib/src/mesa/main/mipmap.c
index 15373ba69..a2f3767a3 100644
--- a/mesalib/src/mesa/main/mipmap.c
+++ b/mesalib/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/mesalib/src/mesa/main/mm.c b/mesalib/src/mesa/main/mm.c
index ab32123a4..473e90fc2 100644
--- a/mesalib/src/mesa/main/mm.c
+++ b/mesalib/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/mesalib/src/mesa/main/pack.c b/mesalib/src/mesa/main/pack.c
index 4c99199d9..a23bc998d 100644
--- a/mesalib/src/mesa/main/pack.c
+++ b/mesalib/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/mesalib/src/mesa/main/readpix.c b/mesalib/src/mesa/main/readpix.c
index 7dc758152..e10f921d2 100644
--- a/mesalib/src/mesa/main/readpix.c
+++ b/mesalib/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/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c
index d6acade3d..643ef516f 100644
--- a/mesalib/src/mesa/main/shaderapi.c
+++ b/mesalib/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");
@@ -703,9 +703,7 @@ shader_source(struct gl_context *ctx, GLuint shader, const GLchar *source)
return;
/* free old shader source string and install new one */
- if (sh->Source) {
- free((void *) sh->Source);
- }
+ free((void *)sh->Source);
sh->Source = source;
sh->CompileStatus = GL_FALSE;
#ifdef DEBUG
@@ -1299,7 +1297,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 +1334,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 +1361,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/mesalib/src/mesa/main/shaderobj.c b/mesalib/src/mesa/main/shaderobj.c
index 16800ae5e..c7f45c88e 100644
--- a/mesalib/src/mesa/main/shaderobj.c
+++ b/mesalib/src/mesa/main/shaderobj.c
@@ -124,8 +124,7 @@ _mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type)
static void
_mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh)
{
- if (sh->Source)
- free((void *) sh->Source);
+ free((void *)sh->Source);
_mesa_reference_program(ctx, &sh->Program, NULL);
ralloc_free(sh);
}
@@ -333,10 +332,8 @@ _mesa_free_shader_program_data(struct gl_context *ctx,
}
shProg->NumShaders = 0;
- if (shProg->Shaders) {
- free(shProg->Shaders);
- shProg->Shaders = NULL;
- }
+ free(shProg->Shaders);
+ shProg->Shaders = NULL;
/* Transform feedback varying vars */
for (i = 0; i < shProg->TransformFeedback.NumVarying; i++) {
diff --git a/mesalib/src/mesa/main/texcompress_cpal.c b/mesalib/src/mesa/main/texcompress_cpal.c
index 2398ded69..ceeec9403 100644
--- a/mesalib/src/mesa/main/texcompress_cpal.c
+++ b/mesalib/src/mesa/main/texcompress_cpal.c
@@ -208,14 +208,13 @@ _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);
}
_mesa_TexImage2D(target, lvl, info->format, w, h, 0,
info->format, info->type, image);
- if (image)
- free(image);
+ free(image);
/* advance index pointer to point to next src mipmap */
if (info->palette_size == 16)
diff --git a/mesalib/src/mesa/main/texcompress_fxt1.c b/mesalib/src/mesa/main/texcompress_fxt1.c
index 8948bd278..92af29ad4 100644
--- a/mesalib/src/mesa/main/texcompress_fxt1.c
+++ b/mesalib/src/mesa/main/texcompress_fxt1.c
@@ -1361,9 +1361,7 @@ fxt1_encode (GLuint width, GLuint height, GLint comps,
}
cleanUp:
- if (newSource != NULL) {
- free(newSource);
- }
+ free(newSource);
}
diff --git a/mesalib/src/mesa/main/texgetimage.c b/mesalib/src/mesa/main/texgetimage.c
index ee43d0d89..a3720699d 100644
--- a/mesalib/src/mesa/main/texgetimage.c
+++ b/mesalib/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/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c
index cdb090542..3cf74f295 100644
--- a/mesalib/src/mesa/main/teximage.c
+++ b/mesalib/src/mesa/main/teximage.c
@@ -1247,11 +1247,12 @@ _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level,
switch (target) {
case GL_PROXY_TEXTURE_1D:
- maxSize = 1 << (ctx->Const.MaxTextureLevels - 1);
- if (width < 2 * border || width > 2 * border + maxSize)
- return GL_FALSE;
if (level >= ctx->Const.MaxTextureLevels)
return GL_FALSE;
+ maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); /* level zero size */
+ maxSize >>= level; /* level size */
+ if (width < 2 * border || width > 2 * border + maxSize)
+ return GL_FALSE;
if (!ctx->Extensions.ARB_texture_non_power_of_two) {
if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
return GL_FALSE;
@@ -1259,13 +1260,14 @@ _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level,
return GL_TRUE;
case GL_PROXY_TEXTURE_2D:
+ if (level >= ctx->Const.MaxTextureLevels)
+ return GL_FALSE;
maxSize = 1 << (ctx->Const.MaxTextureLevels - 1);
+ maxSize >>= level;
if (width < 2 * border || width > 2 * border + maxSize)
return GL_FALSE;
if (height < 2 * border || height > 2 * border + maxSize)
return GL_FALSE;
- if (level >= ctx->Const.MaxTextureLevels)
- return GL_FALSE;
if (!ctx->Extensions.ARB_texture_non_power_of_two) {
if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
return GL_FALSE;
@@ -1275,15 +1277,16 @@ _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level,
return GL_TRUE;
case GL_PROXY_TEXTURE_3D:
+ if (level >= ctx->Const.Max3DTextureLevels)
+ return GL_FALSE;
maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1);
+ maxSize >>= level;
if (width < 2 * border || width > 2 * border + maxSize)
return GL_FALSE;
if (height < 2 * border || height > 2 * border + maxSize)
return GL_FALSE;
if (depth < 2 * border || depth > 2 * border + maxSize)
return GL_FALSE;
- if (level >= ctx->Const.Max3DTextureLevels)
- return GL_FALSE;
if (!ctx->Extensions.ARB_texture_non_power_of_two) {
if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
return GL_FALSE;
@@ -1295,23 +1298,24 @@ _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level,
return GL_TRUE;
case GL_PROXY_TEXTURE_RECTANGLE_NV:
+ if (level != 0)
+ return GL_FALSE;
maxSize = ctx->Const.MaxTextureRectSize;
if (width < 0 || width > maxSize)
return GL_FALSE;
if (height < 0 || height > maxSize)
return GL_FALSE;
- if (level != 0)
- return GL_FALSE;
return GL_TRUE;
case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
+ if (level >= ctx->Const.MaxCubeTextureLevels)
+ return GL_FALSE;
maxSize = 1 << (ctx->Const.MaxCubeTextureLevels - 1);
+ maxSize >>= level;
if (width < 2 * border || width > 2 * border + maxSize)
return GL_FALSE;
if (height < 2 * border || height > 2 * border + maxSize)
return GL_FALSE;
- if (level >= ctx->Const.MaxCubeTextureLevels)
- return GL_FALSE;
if (!ctx->Extensions.ARB_texture_non_power_of_two) {
if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
return GL_FALSE;
@@ -1321,13 +1325,14 @@ _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level,
return GL_TRUE;
case GL_PROXY_TEXTURE_1D_ARRAY_EXT:
+ if (level >= ctx->Const.MaxTextureLevels)
+ return GL_FALSE;
maxSize = 1 << (ctx->Const.MaxTextureLevels - 1);
+ maxSize >>= level;
if (width < 2 * border || width > 2 * border + maxSize)
return GL_FALSE;
if (height < 1 || height > ctx->Const.MaxArrayTextureLayers)
return GL_FALSE;
- if (level >= ctx->Const.MaxTextureLevels)
- return GL_FALSE;
if (!ctx->Extensions.ARB_texture_non_power_of_two) {
if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
return GL_FALSE;
@@ -1335,15 +1340,16 @@ _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level,
return GL_TRUE;
case GL_PROXY_TEXTURE_2D_ARRAY_EXT:
+ if (level >= ctx->Const.MaxTextureLevels)
+ return GL_FALSE;
maxSize = 1 << (ctx->Const.MaxTextureLevels - 1);
+ maxSize >>= level;
if (width < 2 * border || width > 2 * border + maxSize)
return GL_FALSE;
if (height < 2 * border || height > 2 * border + maxSize)
return GL_FALSE;
if (depth < 1 || depth > ctx->Const.MaxArrayTextureLayers)
return GL_FALSE;
- if (level >= ctx->Const.MaxTextureLevels)
- return GL_FALSE;
if (!ctx->Extensions.ARB_texture_non_power_of_two) {
if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
return GL_FALSE;
diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c
index 18429f581..2d055808e 100644
--- a/mesalib/src/mesa/main/texstore.c
+++ b/mesalib/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/mesalib/src/mesa/main/transformfeedback.c b/mesalib/src/mesa/main/transformfeedback.c
index 7679b4b08..26345b100 100644
--- a/mesalib/src/mesa/main/transformfeedback.c
+++ b/mesalib/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/mesalib/src/mesa/main/uniforms.c b/mesalib/src/mesa/main/uniforms.c
index f43d0fbee..04cf0a2b0 100644
--- a/mesalib/src/mesa/main/uniforms.c
+++ b/mesalib/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/mesalib/src/mesa/main/version.c b/mesalib/src/mesa/main/version.c
index fe1e34ea9..7b67765a2 100644
--- a/mesalib/src/mesa/main/version.c
+++ b/mesalib/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/mesalib/src/mesa/main/vsnprintf.c b/mesalib/src/mesa/main/vsnprintf.c
index ab6c740d7..3bbc0a9e2 100644
--- a/mesalib/src/mesa/main/vsnprintf.c
+++ b/mesalib/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;
diff --git a/mesalib/src/mesa/math/m_debug_norm.c b/mesalib/src/mesa/math/m_debug_norm.c
index dc768f306..00efa336d 100644
--- a/mesalib/src/mesa/math/m_debug_norm.c
+++ b/mesalib/src/mesa/math/m_debug_norm.c
@@ -208,7 +208,7 @@ static int test_norm_function( normal_func func, int mtype, long *cycles )
(void) cycles;
- mat->m = (GLfloat *) _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
+ mat->m = _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
mat->inv = m = mat->m;
init_matrix( m );
diff --git a/mesalib/src/mesa/math/m_debug_xform.c b/mesalib/src/mesa/math/m_debug_xform.c
index 7d815664a..2cceaa2f8 100644
--- a/mesalib/src/mesa/math/m_debug_xform.c
+++ b/mesalib/src/mesa/math/m_debug_xform.c
@@ -183,7 +183,7 @@ static int test_transform_function( transform_func func, int psize,
return 0;
}
- mat->m = (GLfloat *) _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
+ mat->m = _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
mat->type = mtypes[mtype];
m = mat->m;
diff --git a/mesalib/src/mesa/math/m_matrix.c b/mesalib/src/mesa/math/m_matrix.c
index b9f22d796..bcd2cae4a 100644
--- a/mesalib/src/mesa/math/m_matrix.c
+++ b/mesalib/src/mesa/math/m_matrix.c
@@ -1468,10 +1468,10 @@ _math_matrix_loadf( GLmatrix *mat, const GLfloat *m )
void
_math_matrix_ctr( GLmatrix *m )
{
- m->m = (GLfloat *) _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
+ m->m = _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
if (m->m)
memcpy( m->m, Identity, sizeof(Identity) );
- m->inv = (GLfloat *) _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
+ m->inv = _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
if (m->inv)
memcpy( m->inv, Identity, sizeof(Identity) );
m->type = MATRIX_IDENTITY;
diff --git a/mesalib/src/mesa/math/m_trans_tmp.h b/mesalib/src/mesa/math/m_trans_tmp.h
index 08fb4d1e9..76ed83209 100644
--- a/mesalib/src/mesa/math/m_trans_tmp.h
+++ b/mesalib/src/mesa/math/m_trans_tmp.h
@@ -29,7 +29,7 @@
#ifdef DEST_4F
static void DEST_4F( GLfloat (*t)[4],
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
ARGS )
{
@@ -55,7 +55,7 @@ static void DEST_4F( GLfloat (*t)[4],
#ifdef DEST_4FN
static void DEST_4FN( GLfloat (*t)[4],
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
ARGS )
{
@@ -80,7 +80,7 @@ static void DEST_4FN( GLfloat (*t)[4],
#ifdef DEST_3FN
static void DEST_3FN( GLfloat (*t)[3],
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
ARGS )
{
@@ -102,7 +102,7 @@ static void DEST_3FN( GLfloat (*t)[3],
#ifdef DEST_1F
static void DEST_1F( GLfloat *t,
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
ARGS )
{
@@ -122,7 +122,7 @@ static void DEST_1F( GLfloat *t,
#ifdef DEST_4UB
static void DEST_4UB( GLubyte (*t)[4],
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
ARGS )
{
@@ -146,7 +146,7 @@ static void DEST_4UB( GLubyte (*t)[4],
#ifdef DEST_4US
static void DEST_4US( GLushort (*t)[4],
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
ARGS )
{
@@ -170,7 +170,7 @@ static void DEST_4US( GLushort (*t)[4],
#ifdef DEST_1UB
static void DEST_1UB( GLubyte *t,
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
ARGS )
{
@@ -191,7 +191,7 @@ static void DEST_1UB( GLubyte *t,
#ifdef DEST_1UI
static void DEST_1UI( GLuint *t,
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
ARGS )
{
diff --git a/mesalib/src/mesa/math/m_translate.c b/mesalib/src/mesa/math/m_translate.c
index 51daf7bfd..1da4de372 100644
--- a/mesalib/src/mesa/math/m_translate.c
+++ b/mesalib/src/mesa/math/m_translate.c
@@ -37,43 +37,43 @@
typedef void (*trans_1f_func)(GLfloat *to,
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLuint start,
GLuint n );
typedef void (*trans_1ui_func)(GLuint *to,
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLuint start,
GLuint n );
typedef void (*trans_1ub_func)(GLubyte *to,
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLuint start,
GLuint n );
typedef void (*trans_4ub_func)(GLubyte (*to)[4],
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLuint start,
GLuint n );
typedef void (*trans_4us_func)(GLushort (*to)[4],
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLuint start,
GLuint n );
typedef void (*trans_4f_func)(GLfloat (*to)[4],
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLuint start,
GLuint n );
typedef void (*trans_3fn_func)(GLfloat (*to)[3],
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLuint start,
GLuint n );
@@ -530,7 +530,7 @@ static trans_4f_func _math_trans_4fn_tab[5][MAX_TYPES];
static void trans_4_GLubyte_4ub_raw(GLubyte (*t)[4],
- CONST void *Ptr,
+ const void *Ptr,
GLuint stride,
ARGS )
{
@@ -625,7 +625,7 @@ void _math_init_translate( void )
* Translate vector of values to GLfloat [1].
*/
void _math_trans_1f(GLfloat *to,
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLenum type,
GLuint start,
@@ -638,7 +638,7 @@ void _math_trans_1f(GLfloat *to,
* Translate vector of values to GLuint [1].
*/
void _math_trans_1ui(GLuint *to,
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLenum type,
GLuint start,
@@ -651,7 +651,7 @@ void _math_trans_1ui(GLuint *to,
* Translate vector of values to GLubyte [1].
*/
void _math_trans_1ub(GLubyte *to,
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLenum type,
GLuint start,
@@ -665,7 +665,7 @@ void _math_trans_1ub(GLubyte *to,
* Translate vector of values to GLubyte [4].
*/
void _math_trans_4ub(GLubyte (*to)[4],
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLenum type,
GLuint size,
@@ -679,7 +679,7 @@ void _math_trans_4ub(GLubyte (*to)[4],
* Translate vector of values to GLchan [4].
*/
void _math_trans_4chan( GLchan (*to)[4],
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLenum type,
GLuint size,
@@ -699,7 +699,7 @@ void _math_trans_4chan( GLchan (*to)[4],
* Translate vector of values to GLushort [4].
*/
void _math_trans_4us(GLushort (*to)[4],
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLenum type,
GLuint size,
@@ -713,7 +713,7 @@ void _math_trans_4us(GLushort (*to)[4],
* Translate vector of values to GLfloat [4].
*/
void _math_trans_4f(GLfloat (*to)[4],
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLenum type,
GLuint size,
@@ -727,7 +727,7 @@ void _math_trans_4f(GLfloat (*to)[4],
* Translate vector of values to GLfloat[4], normalized to [-1, 1].
*/
void _math_trans_4fn(GLfloat (*to)[4],
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLenum type,
GLuint size,
@@ -741,7 +741,7 @@ void _math_trans_4fn(GLfloat (*to)[4],
* Translate vector of values to GLfloat[3], normalized to [-1, 1].
*/
void _math_trans_3fn(GLfloat (*to)[3],
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLenum type,
GLuint start,
diff --git a/mesalib/src/mesa/math/m_translate.h b/mesalib/src/mesa/math/m_translate.h
index bf7485c8c..8fec6f14b 100644
--- a/mesalib/src/mesa/math/m_translate.h
+++ b/mesalib/src/mesa/math/m_translate.h
@@ -48,28 +48,28 @@
extern void _math_trans_1f(GLfloat *to,
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLenum type,
GLuint start,
GLuint n );
extern void _math_trans_1ui(GLuint *to,
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLenum type,
GLuint start,
GLuint n );
extern void _math_trans_1ub(GLubyte *to,
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLenum type,
GLuint start,
GLuint n );
extern void _math_trans_4ub(GLubyte (*to)[4],
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLenum type,
GLuint size,
@@ -77,7 +77,7 @@ extern void _math_trans_4ub(GLubyte (*to)[4],
GLuint n );
extern void _math_trans_4chan( GLchan (*to)[4],
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLenum type,
GLuint size,
@@ -85,7 +85,7 @@ extern void _math_trans_4chan( GLchan (*to)[4],
GLuint n );
extern void _math_trans_4us(GLushort (*to)[4],
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLenum type,
GLuint size,
@@ -94,7 +94,7 @@ extern void _math_trans_4us(GLushort (*to)[4],
/** Convert to floats w/out normalization (i.e. just cast) */
extern void _math_trans_4f(GLfloat (*to)[4],
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLenum type,
GLuint size,
@@ -103,7 +103,7 @@ extern void _math_trans_4f(GLfloat (*to)[4],
/** Convert to normalized floats in [0,1] or [-1, 1] */
extern void _math_trans_4fn(GLfloat (*to)[4],
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLenum type,
GLuint size,
@@ -111,7 +111,7 @@ extern void _math_trans_4fn(GLfloat (*to)[4],
GLuint n );
extern void _math_trans_3fn(GLfloat (*to)[3],
- CONST void *ptr,
+ const void *ptr,
GLuint stride,
GLenum type,
GLuint start,
diff --git a/mesalib/src/mesa/math/m_xform.h b/mesalib/src/mesa/math/m_xform.h
index 14ac956a7..280248883 100644
--- a/mesalib/src/mesa/math/m_xform.h
+++ b/mesalib/src/mesa/math/m_xform.h
@@ -108,21 +108,21 @@ typedef GLvector4f * (_XFORMAPIP clip_func)( GLvector4f *vClip,
typedef void (*dotprod_func)( GLfloat *out,
GLuint out_stride,
- CONST GLvector4f *coord_vec,
- CONST GLfloat plane[4] );
+ const GLvector4f *coord_vec,
+ const GLfloat plane[4] );
typedef void (*vec_copy_func)( GLvector4f *to,
- CONST GLvector4f *from );
+ const GLvector4f *from );
/*
* Functions for transformation of normals in the VB.
*/
-typedef void (_NORMAPIP normal_func)( CONST GLmatrix *mat,
+typedef void (_NORMAPIP normal_func)( const GLmatrix *mat,
GLfloat scale,
- CONST GLvector4f *in,
- CONST GLfloat lengths[],
+ const GLvector4f *in,
+ const GLfloat lengths[],
GLvector4f *dest );
@@ -142,8 +142,8 @@ typedef void (_NORMAPIP normal_func)( CONST GLmatrix *mat,
* parameter, to allow a unified interface.
*/
typedef void (_XFORMAPIP transform_func)( GLvector4f *to_vec,
- CONST GLfloat m[16],
- CONST GLvector4f *from_vec );
+ const GLfloat m[16],
+ const GLvector4f *from_vec );
extern dotprod_func _mesa_dotprod_tab[5];
diff --git a/mesalib/src/mesa/program/arbprogparse.c b/mesalib/src/mesa/program/arbprogparse.c
index 72e51dd0f..527bb936e 100644
--- a/mesalib/src/mesa/program/arbprogparse.c
+++ b/mesalib/src/mesa/program/arbprogparse.c
@@ -84,8 +84,7 @@ _mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target,
return;
}
- if (program->Base.String != NULL)
- free(program->Base.String);
+ free(program->Base.String);
/* Copy the relevant contents of the arb_program struct into the
* fragment_program struct.
@@ -122,8 +121,7 @@ _mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target,
program->UsesKill = state.fragment.UsesKill;
program->UsesDFdy = state.fragment.UsesDFdy;
- if (program->Base.Instructions)
- free(program->Base.Instructions);
+ free(program->Base.Instructions);
program->Base.Instructions = prog.Instructions;
if (program->Base.Parameters)
@@ -179,8 +177,7 @@ _mesa_parse_arb_vertex_program(struct gl_context *ctx, GLenum target,
return;
}
- if (program->Base.String != NULL)
- free(program->Base.String);
+ free(program->Base.String);
/* Copy the relevant contents of the arb_program struct into the
* vertex_program struct.
@@ -202,8 +199,7 @@ _mesa_parse_arb_vertex_program(struct gl_context *ctx, GLenum target,
program->IsPositionInvariant = (state.option.PositionInvariant)
? GL_TRUE : GL_FALSE;
- if (program->Base.Instructions)
- free(program->Base.Instructions);
+ free(program->Base.Instructions);
program->Base.Instructions = prog.Instructions;
if (program->Base.Parameters)
diff --git a/mesalib/src/mesa/program/nvfragparse.c b/mesalib/src/mesa/program/nvfragparse.c
index f61221c11..f251d7e6c 100644
--- a/mesalib/src/mesa/program/nvfragparse.c
+++ b/mesalib/src/mesa/program/nvfragparse.c
@@ -1236,7 +1236,7 @@ Parse_PrintInstruction(struct parse_state *parseState,
for (len = 0; str[len] != '\''; len++) /* find closing quote */
;
parseState->pos += len + 1;
- msg = (GLubyte*) malloc(len + 1);
+ msg = malloc(len + 1);
memcpy(msg, str, len);
msg[len] = 0;
@@ -1481,7 +1481,7 @@ _mesa_parse_nv_fragment_program(struct gl_context *ctx, GLenum dstTarget,
GLubyte *programString;
/* Make a null-terminated copy of the program string */
- programString = (GLubyte *) malloc(len + 1);
+ programString = malloc(len + 1);
if (!programString) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
return;
@@ -1549,14 +1549,10 @@ _mesa_parse_nv_fragment_program(struct gl_context *ctx, GLenum dstTarget,
/* install the program */
program->Base.Target = target;
- if (program->Base.String) {
- free(program->Base.String);
- }
+ free(program->Base.String);
program->Base.String = programString;
program->Base.Format = GL_PROGRAM_FORMAT_ASCII_ARB;
- if (program->Base.Instructions) {
- free(program->Base.Instructions);
- }
+ free(program->Base.Instructions);
program->Base.Instructions = newInst;
program->Base.NumInstructions = parseState.numInst;
program->Base.InputsRead = parseState.inputsRead;
diff --git a/mesalib/src/mesa/program/nvvertparse.c b/mesalib/src/mesa/program/nvvertparse.c
index 62b27b9f4..6272c2f7f 100644
--- a/mesalib/src/mesa/program/nvvertparse.c
+++ b/mesalib/src/mesa/program/nvvertparse.c
@@ -1050,7 +1050,7 @@ Parse_PrintInstruction(struct parse_state *parseState, struct prog_instruction *
for (len = 0; str[len] != '\''; len++) /* find closing quote */
;
parseState->pos += len + 1;
- msg = (GLubyte*) malloc(len + 1);
+ msg = malloc(len + 1);
memcpy(msg, str, len);
msg[len] = 0;
@@ -1293,7 +1293,7 @@ _mesa_parse_nv_vertex_program(struct gl_context *ctx, GLenum dstTarget,
GLubyte *programString;
/* Make a null-terminated copy of the program string */
- programString = (GLubyte *) malloc(len + 1);
+ programString = malloc(len + 1);
if (!programString) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
return;
@@ -1382,14 +1382,10 @@ _mesa_parse_nv_vertex_program(struct gl_context *ctx, GLenum dstTarget,
/* install the program */
program->Base.Target = target;
- if (program->Base.String) {
- free(program->Base.String);
- }
+ free(program->Base.String);
program->Base.String = programString;
program->Base.Format = GL_PROGRAM_FORMAT_ASCII_ARB;
- if (program->Base.Instructions) {
- free(program->Base.Instructions);
- }
+ free(program->Base.Instructions);
program->Base.Instructions = newInst;
program->Base.InputsRead = parseState.inputsRead;
if (parseState.isPositionInvariant)
diff --git a/mesalib/src/mesa/program/prog_cache.c b/mesalib/src/mesa/program/prog_cache.c
index 2ccedb5d7..47f926b1b 100644
--- a/mesalib/src/mesa/program/prog_cache.c
+++ b/mesalib/src/mesa/program/prog_cache.c
@@ -88,7 +88,7 @@ rehash(struct gl_program_cache *cache)
cache->last = NULL;
size = cache->size * 3;
- items = (struct cache_item**) malloc(size * sizeof(*items));
+ items = malloc(size * sizeof(*items));
memset(items, 0, size * sizeof(*items));
for (i = 0; i < cache->size; i++)
@@ -141,7 +141,7 @@ _mesa_new_program_cache(void)
struct gl_program_cache *cache = CALLOC_STRUCT(gl_program_cache);
if (cache) {
cache->size = 17;
- cache->items = (struct cache_item **)
+ cache->items =
calloc(1, cache->size * sizeof(struct cache_item));
if (!cache->items) {
free(cache);
diff --git a/mesalib/src/mesa/program/prog_instruction.c b/mesalib/src/mesa/program/prog_instruction.c
index 5d6cb476c..d69d7b2d4 100644
--- a/mesalib/src/mesa/program/prog_instruction.c
+++ b/mesalib/src/mesa/program/prog_instruction.c
@@ -69,7 +69,7 @@ _mesa_init_instructions(struct prog_instruction *inst, GLuint count)
struct prog_instruction *
_mesa_alloc_instructions(GLuint numInst)
{
- return (struct prog_instruction *)
+ return
calloc(1, numInst * sizeof(struct prog_instruction));
}
@@ -127,10 +127,8 @@ _mesa_free_instructions(struct prog_instruction *inst, GLuint count)
{
GLuint i;
for (i = 0; i < count; i++) {
- if (inst[i].Data)
- free(inst[i].Data);
- if (inst[i].Comment)
- free((char *) inst[i].Comment);
+ free(inst[i].Data);
+ free((char *)inst[i].Comment);
}
free(inst);
}
diff --git a/mesalib/src/mesa/program/prog_optimize.c b/mesalib/src/mesa/program/prog_optimize.c
index 25d9684b1..e89e8d6a4 100644
--- a/mesalib/src/mesa/program/prog_optimize.c
+++ b/mesalib/src/mesa/program/prog_optimize.c
@@ -260,7 +260,7 @@ _mesa_remove_dead_code_global(struct gl_program *prog)
/*_mesa_print_program(prog);*/
}
- removeInst = (GLboolean *)
+ removeInst =
calloc(1, prog->NumInstructions * sizeof(GLboolean));
/* Determine which temps are read and written */
@@ -604,7 +604,7 @@ _mesa_remove_dead_code_local(struct gl_program *prog)
GLboolean *removeInst;
GLuint i, arg, rem = 0;
- removeInst = (GLboolean *)
+ removeInst =
calloc(1, prog->NumInstructions * sizeof(GLboolean));
for (i = 0; i < prog->NumInstructions; i++) {
@@ -745,7 +745,7 @@ _mesa_remove_extra_moves(struct gl_program *prog)
_mesa_print_program(prog);
}
- removeInst = (GLboolean *)
+ removeInst =
calloc(1, prog->NumInstructions * sizeof(GLboolean));
/*
diff --git a/mesalib/src/mesa/program/prog_parameter.c b/mesalib/src/mesa/program/prog_parameter.c
index 2018fa520..b9f4d9d57 100644
--- a/mesalib/src/mesa/program/prog_parameter.c
+++ b/mesalib/src/mesa/program/prog_parameter.c
@@ -80,8 +80,7 @@ _mesa_free_parameter_list(struct gl_program_parameter_list *paramList)
{
GLuint i;
for (i = 0; i < paramList->NumParameters; i++) {
- if (paramList->Parameters[i].Name)
- free((void *) paramList->Parameters[i].Name);
+ free((void *)paramList->Parameters[i].Name);
}
free(paramList->Parameters);
if (paramList->ParameterValues)
diff --git a/mesalib/src/mesa/program/program.c b/mesalib/src/mesa/program/program.c
index 15337f4d8..becb77c1d 100644
--- a/mesalib/src/mesa/program/program.c
+++ b/mesalib/src/mesa/program/program.c
@@ -249,7 +249,7 @@ _mesa_find_line_column(const GLubyte *string, const GLubyte *pos,
while (*p != 0 && *p != '\n')
p++;
len = p - lineStart;
- s = (GLubyte *) malloc(len + 1);
+ s = malloc(len + 1);
memcpy(s, lineStart, len);
s[len] = 0;
@@ -382,8 +382,7 @@ _mesa_delete_program(struct gl_context *ctx, struct gl_program *prog)
if (prog == &_mesa_DummyProgram)
return;
- if (prog->String)
- free(prog->String);
+ free(prog->String);
if (prog->Instructions) {
_mesa_free_instructions(prog->Instructions, prog->NumInstructions);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
index 9f1b427a9..b2c6327a0 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -875,8 +875,8 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
pixels = _mesa_map_pbo_source(ctx, &clippedUnpack, pixels);
assert(pixels);
- sValues = (GLubyte *) malloc(width * sizeof(GLubyte));
- zValues = (GLuint *) malloc(width * sizeof(GLuint));
+ sValues = malloc(width * sizeof(GLubyte));
+ zValues = malloc(width * sizeof(GLuint));
if (sValues && zValues) {
GLint row;
@@ -1598,7 +1598,7 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
/* copy image from ptRead surface to ptTex surface */
if (type == GL_COLOR) {
/* alternate path using get/put_tile() */
- GLfloat *buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
+ GLfloat *buf = malloc(width * height * 4 * sizeof(GLfloat));
enum pipe_format readFormat, drawFormat;
readFormat = util_format_linear(rbRead->texture->format);
drawFormat = util_format_linear(pt->format);
@@ -1610,7 +1610,7 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
}
else {
/* GL_DEPTH */
- GLuint *buf = (GLuint *) malloc(width * height * sizeof(GLuint));
+ GLuint *buf = malloc(width * height * sizeof(GLuint));
pipe_get_tile_z(pipe, ptRead, 0, 0, readW, readH, buf);
pipe_put_tile_z(pipe, ptTex, pack.SkipPixels, pack.SkipRows,
readW, readH, buf);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c
index ed3bbc725..518b680f0 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c
@@ -648,7 +648,7 @@ decompress_with_blit(struct gl_context * ctx,
enum pipe_format pformat = util_format_linear(dst_texture->format);
GLfloat *rgba;
- rgba = (GLfloat *) malloc(width * 4 * sizeof(GLfloat));
+ rgba = malloc(width * 4 * sizeof(GLfloat));
if (!rgba) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage()");
goto end;
@@ -775,7 +775,7 @@ fallback_copy_texsubimage(struct gl_context *ctx,
yStep = 1;
}
- data = (uint *) malloc(width * sizeof(uint));
+ data = malloc(width * sizeof(uint));
if (data) {
/* To avoid a large temp memory allocation, do copy row by row */
@@ -796,7 +796,7 @@ fallback_copy_texsubimage(struct gl_context *ctx,
else {
/* RGBA format */
GLfloat *tempSrc =
- (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
+ malloc(width * height * 4 * sizeof(GLfloat));
if (tempSrc && texDest) {
const GLint dims = 2;
@@ -835,8 +835,7 @@ fallback_copy_texsubimage(struct gl_context *ctx,
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage");
}
- if (tempSrc)
- free(tempSrc);
+ free(tempSrc);
}
st_texture_image_unmap(st, stImage);
diff --git a/mesalib/src/mesa/swrast/s_context.c b/mesalib/src/mesa/swrast/s_context.c
index 53497bc9c..31a12dade 100644
--- a/mesalib/src/mesa/swrast/s_context.c
+++ b/mesalib/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 ||
@@ -829,8 +829,7 @@ _swrast_DestroyContext( struct gl_context *ctx )
}
free( swrast->SpanArrays );
- if (swrast->ZoomedArrays)
- free( swrast->ZoomedArrays );
+ free( swrast->ZoomedArrays );
free( swrast->TexelBuffer );
free(swrast->stencil_temp.buf1);
diff --git a/mesalib/src/mesa/swrast/s_copypix.c b/mesalib/src/mesa/swrast/s_copypix.c
index cf419c328..bbd1f228c 100644
--- a/mesalib/src/mesa/swrast/s_copypix.c
+++ b/mesalib/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/mesalib/src/mesa/swrast/s_depth.c b/mesalib/src/mesa/swrast/s_depth.c
index 26126a932..969b75f07 100644
--- a/mesalib/src/mesa/swrast/s_depth.c
+++ b/mesalib/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/mesalib/src/mesa/swrast/s_drawpix.c b/mesalib/src/mesa/swrast/s_drawpix.c
index 1fa64c378..7665408fd 100644
--- a/mesalib/src/mesa/swrast/s_drawpix.c
+++ b/mesalib/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;
@@ -493,9 +493,7 @@ draw_rgba_pixels( struct gl_context *ctx, GLint x, GLint y,
span.array->ChanType = CHAN_TYPE;
}
- if (convImage) {
- free(convImage);
- }
+ free(convImage);
swrast_render_finish(ctx);
}
@@ -592,7 +590,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/mesalib/src/mesa/swrast/s_renderbuffer.c b/mesalib/src/mesa/swrast/s_renderbuffer.c
index e468bdb16..b1fb57823 100644
--- a/mesalib/src/mesa/swrast/s_renderbuffer.c
+++ b/mesalib/src/mesa/swrast/s_renderbuffer.c
@@ -119,10 +119,8 @@ soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
bpp = _mesa_get_format_bytes(rb->Format);
/* free old buffer storage */
- if (srb->Buffer) {
- free(srb->Buffer);
- srb->Buffer = NULL;
- }
+ free(srb->Buffer);
+ srb->Buffer = NULL;
srb->RowStride = width * bpp;
@@ -170,10 +168,8 @@ soft_renderbuffer_delete(struct gl_renderbuffer *rb)
{
struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
- if (srb->Buffer) {
- free(srb->Buffer);
- srb->Buffer = NULL;
- }
+ free(srb->Buffer);
+ srb->Buffer = NULL;
_mesa_delete_renderbuffer(rb);
}
diff --git a/mesalib/src/mesa/swrast/s_texcombine.c b/mesalib/src/mesa/swrast/s_texcombine.c
index 9c745d118..1a2db35e2 100644
--- a/mesalib/src/mesa/swrast/s_texcombine.c
+++ b/mesalib/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/mesalib/src/mesa/swrast/s_texfilter.c b/mesalib/src/mesa/swrast/s_texfilter.c
index 152b1ff3e..0a91cca06 100644
--- a/mesalib/src/mesa/swrast/s_texfilter.c
+++ b/mesalib/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/mesalib/src/mesa/swrast/s_texture.c b/mesalib/src/mesa/swrast/s_texture.c
index 1b73d46e4..8ae3d5bd0 100644
--- a/mesalib/src/mesa/swrast/s_texture.c
+++ b/mesalib/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;
@@ -144,10 +144,8 @@ _swrast_free_texture_image_buffer(struct gl_context *ctx,
swImage->Buffer = NULL;
}
- if (swImage->ImageOffsets) {
- free(swImage->ImageOffsets);
- swImage->ImageOffsets = NULL;
- }
+ free(swImage->ImageOffsets);
+ swImage->ImageOffsets = NULL;
}
diff --git a/mesalib/src/mesa/swrast/s_zoom.c b/mesalib/src/mesa/swrast/s_zoom.c
index 9304002d2..24bfa22bf 100644
--- a/mesalib/src/mesa/swrast/s_zoom.c
+++ b/mesalib/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;
diff --git a/mesalib/src/mesa/swrast_setup/ss_context.c b/mesalib/src/mesa/swrast_setup/ss_context.c
index 40268be2d..9444611f1 100644
--- a/mesalib/src/mesa/swrast_setup/ss_context.c
+++ b/mesalib/src/mesa/swrast_setup/ss_context.c
@@ -49,7 +49,7 @@
GLboolean
_swsetup_CreateContext( struct gl_context *ctx )
{
- SScontext *swsetup = (SScontext *) calloc(1, sizeof(SScontext));
+ SScontext *swsetup = calloc(1, sizeof(SScontext));
if (!swsetup)
return GL_FALSE;
diff --git a/mesalib/src/mesa/tnl/t_context.c b/mesalib/src/mesa/tnl/t_context.c
index aa6783932..df3a11666 100644
--- a/mesalib/src/mesa/tnl/t_context.c
+++ b/mesalib/src/mesa/tnl/t_context.c
@@ -50,7 +50,7 @@ _tnl_CreateContext( struct gl_context *ctx )
/* Create the TNLcontext structure
*/
- ctx->swtnl_context = tnl = (TNLcontext *) calloc(1, sizeof(TNLcontext));
+ ctx->swtnl_context = tnl = calloc(1, sizeof(TNLcontext));
if (!tnl) {
return GL_FALSE;
diff --git a/mesalib/src/mesa/tnl/t_vb_program.c b/mesalib/src/mesa/tnl/t_vb_program.c
index 271137f87..f2e76115e 100644
--- a/mesalib/src/mesa/tnl/t_vb_program.c
+++ b/mesalib/src/mesa/tnl/t_vb_program.c
@@ -521,7 +521,7 @@ init_vp(struct gl_context *ctx, struct tnl_pipeline_stage *stage)
/* a few other misc allocations */
_mesa_vector4f_alloc( &store->ndcCoords, 0, size, 32 );
- store->clipmask = (GLubyte *) _mesa_align_malloc(sizeof(GLubyte)*size, 32 );
+ store->clipmask = _mesa_align_malloc(sizeof(GLubyte)*size, 32 );
return GL_TRUE;
}
diff --git a/mesalib/src/mesa/tnl/t_vb_texgen.c b/mesalib/src/mesa/tnl/t_vb_texgen.c
index c757ac522..8ba67f3c0 100644
--- a/mesalib/src/mesa/tnl/t_vb_texgen.c
+++ b/mesalib/src/mesa/tnl/t_vb_texgen.c
@@ -570,8 +570,8 @@ static GLboolean alloc_texgen_data( struct gl_context *ctx,
for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++)
_mesa_vector4f_alloc( &store->texcoord[i], 0, VB->Size, 32 );
- store->tmp_f = (GLfloat (*)[3]) malloc(VB->Size * sizeof(GLfloat) * 3);
- store->tmp_m = (GLfloat *) malloc(VB->Size * sizeof(GLfloat));
+ store->tmp_f = malloc(VB->Size * sizeof(GLfloat) * 3);
+ store->tmp_m = malloc(VB->Size * sizeof(GLfloat));
return GL_TRUE;
}
@@ -589,8 +589,8 @@ static void free_texgen_data( struct tnl_pipeline_stage *stage )
_mesa_vector4f_free( &store->texcoord[i] );
- if (store->tmp_f) free( store->tmp_f );
- if (store->tmp_m) free( store->tmp_m );
+ free( store->tmp_f );
+ free( store->tmp_m );
free( store );
stage->privatePtr = NULL;
}
diff --git a/mesalib/src/mesa/tnl/t_vb_vertex.c b/mesalib/src/mesa/tnl/t_vb_vertex.c
index 64795a57e..8f296f54b 100644
--- a/mesalib/src/mesa/tnl/t_vb_vertex.c
+++ b/mesalib/src/mesa/tnl/t_vb_vertex.c
@@ -245,7 +245,7 @@ static GLboolean init_vertex_stage( struct gl_context *ctx,
_mesa_vector4f_alloc( &store->clip, 0, size, 32 );
_mesa_vector4f_alloc( &store->proj, 0, size, 32 );
- store->clipmask = (GLubyte *) _mesa_align_malloc(sizeof(GLubyte)*size, 32 );
+ store->clipmask = _mesa_align_malloc(sizeof(GLubyte)*size, 32 );
if (!store->clipmask ||
!store->eye.data ||
diff --git a/mesalib/src/mesa/tnl/t_vertex.c b/mesalib/src/mesa/tnl/t_vertex.c
index 7e83d454d..ce3e32165 100644
--- a/mesalib/src/mesa/tnl/t_vertex.c
+++ b/mesalib/src/mesa/tnl/t_vertex.c
@@ -87,7 +87,7 @@ void _tnl_register_fastpath( struct tnl_clipspace *vtx,
fastpath->attr_count = vtx->attr_count;
fastpath->match_strides = match_strides;
fastpath->func = vtx->emit;
- fastpath->attr = (struct tnl_attr_type *)
+ fastpath->attr =
malloc(vtx->attr_count * sizeof(fastpath->attr[0]));
for (i = 0; i < vtx->attr_count; i++) {
@@ -495,7 +495,7 @@ void _tnl_init_vertices( struct gl_context *ctx,
if (max_vertex_size > vtx->max_vertex_size) {
_tnl_free_vertices( ctx );
vtx->max_vertex_size = max_vertex_size;
- vtx->vertex_buf = (GLubyte *)_mesa_align_calloc(vb_size * max_vertex_size, 32 );
+ vtx->vertex_buf = _mesa_align_calloc(vb_size * max_vertex_size, 32 );
invalidate_funcs(vtx);
}
diff --git a/mesalib/src/mesa/vbo/vbo_exec_api.c b/mesalib/src/mesa/vbo/vbo_exec_api.c
index 781e360d2..ded711b9f 100644
--- a/mesalib/src/mesa/vbo/vbo_exec_api.c
+++ b/mesalib/src/mesa/vbo/vbo_exec_api.c
@@ -1179,7 +1179,7 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec )
ctx->Shared->NullBufferObj);
ASSERT(!exec->vtx.buffer_map);
- exec->vtx.buffer_map = (GLfloat *)_mesa_align_malloc(VBO_VERT_BUFFER_SIZE, 64);
+ exec->vtx.buffer_map = _mesa_align_malloc(VBO_VERT_BUFFER_SIZE, 64);
exec->vtx.buffer_ptr = exec->vtx.buffer_map;
vbo_exec_vtxfmt_init( exec );
diff --git a/mesalib/src/mesa/vbo/vbo_primitive_restart.c b/mesalib/src/mesa/vbo/vbo_primitive_restart.c
index 18d851c1e..6f9d61c9b 100644
--- a/mesalib/src/mesa/vbo/vbo_primitive_restart.c
+++ b/mesalib/src/mesa/vbo/vbo_primitive_restart.c
@@ -86,7 +86,7 @@ find_sub_primitives(const void *elements, unsigned element_size,
GLuint scan_index;
unsigned scan_num;
- sub_prims = (struct sub_primitive *)
+ sub_prims =
malloc(max_prims * sizeof(struct sub_primitive));
if (!sub_prims) {
@@ -226,8 +226,6 @@ vbo_sw_primitive_restart(struct gl_context *ctx,
}
}
- if (sub_prims) {
- free(sub_prims);
- }
+ free(sub_prims);
}
diff --git a/mesalib/src/mesa/vbo/vbo_rebase.c b/mesalib/src/mesa/vbo/vbo_rebase.c
index fff9df0c2..d0bf6c59d 100644
--- a/mesalib/src/mesa/vbo/vbo_rebase.c
+++ b/mesalib/src/mesa/vbo/vbo_rebase.c
@@ -146,7 +146,7 @@ void vbo_rebase_prims( struct gl_context *ctx,
/* If we can just tell the hardware or the TNL to interpret our
* indices with a different base, do so.
*/
- tmp_prims = (struct _mesa_prim *)malloc(sizeof(*prim) * nr_prims);
+ tmp_prims = malloc(sizeof(*prim) * nr_prims);
for (i = 0; i < nr_prims; i++) {
tmp_prims[i] = prim[i];
@@ -195,7 +195,7 @@ void vbo_rebase_prims( struct gl_context *ctx,
else {
/* Otherwise the primitives need adjustment.
*/
- tmp_prims = (struct _mesa_prim *)malloc(sizeof(*prim) * nr_prims);
+ tmp_prims = malloc(sizeof(*prim) * nr_prims);
for (i = 0; i < nr_prims; i++) {
/* If this fails, it could indicate an application error:
@@ -242,11 +242,9 @@ void vbo_rebase_prims( struct gl_context *ctx,
ctx->Array._DrawArrays = saved_arrays;
ctx->NewDriverState |= ctx->DriverFlags.NewArray;
- if (tmp_indices)
- free(tmp_indices);
+ free(tmp_indices);
- if (tmp_prims)
- free(tmp_prims);
+ free(tmp_prims);
}
diff --git a/mesalib/src/mesa/vbo/vbo_save_api.c b/mesalib/src/mesa/vbo/vbo_save_api.c
index 636aa1fdb..f7936610c 100644
--- a/mesalib/src/mesa/vbo/vbo_save_api.c
+++ b/mesalib/src/mesa/vbo/vbo_save_api.c
@@ -1577,10 +1577,8 @@ vbo_destroy_vertex_list(struct gl_context *ctx, void *data)
if (--node->prim_store->refcount == 0)
free(node->prim_store);
- if (node->current_data) {
- free(node->current_data);
- node->current_data = NULL;
- }
+ free(node->current_data);
+ node->current_data = NULL;
}
diff --git a/mesalib/src/mesa/x86/common_x86.c b/mesalib/src/mesa/x86/common_x86.c
index b70ee5084..629950723 100644
--- a/mesalib/src/mesa/x86/common_x86.c
+++ b/mesalib/src/mesa/x86/common_x86.c
@@ -82,7 +82,7 @@ extern void _mesa_test_os_sse_support( void );
extern void _mesa_test_os_sse_exception_support( void );
-#if defined(WIN32)
+#if defined(_WIN32)
#ifndef STATUS_FLOAT_MULTIPLE_TRAPS
# define STATUS_FLOAT_MULTIPLE_TRAPS (0xC00002B5L)
#endif
@@ -110,7 +110,7 @@ static LONG WINAPI ExceptionFilter(LPEXCEPTION_POINTERS exp)
return EXCEPTION_CONTINUE_EXECUTION;
}
-#endif /* WIN32 */
+#endif /* _WIN32 */
/**
@@ -149,7 +149,7 @@ void _mesa_check_os_sse_support( void )
if (ret || !enabled)
_mesa_x86_cpu_features &= ~(X86_FEATURE_XMM);
}
-#elif defined(WIN32)
+#elif defined(_WIN32)
LPTOP_LEVEL_EXCEPTION_FILTER oldFilter;
/* Install our ExceptionFilter */
diff --git a/mesalib/src/mesa/x86/norm_args.h b/mesalib/src/mesa/x86/norm_args.h
index 5d352838b..e22f8bbd7 100644
--- a/mesalib/src/mesa/x86/norm_args.h
+++ b/mesalib/src/mesa/x86/norm_args.h
@@ -36,10 +36,10 @@
/* Offsets for normal_func arguments
*
- * typedef void (*normal_func)( CONST GLmatrix *mat,
+ * typedef void (*normal_func)( const GLmatrix *mat,
* GLfloat scale,
- * CONST GLvector4f *in,
- * CONST GLfloat lengths[],
+ * const GLvector4f *in,
+ * const GLfloat lengths[],
* GLvector4f *dest );
*/
#define OFFSET_MAT 4