[Mesa-dev] [PATCH 1/3] mesa: s/MALLOC/malloc/

Brian Paul brian.e.paul at gmail.com
Fri Aug 31 07:17:23 PDT 2012


From: Brian Paul <brianp at vmware.com>

v2: replace instances in dri/common/ dirs
---
 src/gallium/state_trackers/glx/xlib/glx_usefont.c |    2 +-
 src/gallium/state_trackers/glx/xlib/xm_api.c      |    4 ++--
 src/mesa/drivers/dri/common/xmlconfig.c           |   14 +++++++-------
 src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c  |    2 +-
 src/mesa/drivers/x11/xfonts.c                     |    2 +-
 src/mesa/drivers/x11/xm_api.c                     |    4 ++--
 src/mesa/drivers/x11/xm_buffer.c                  |    2 +-
 src/mesa/main/attrib.c                            |    2 +-
 src/mesa/main/errors.c                            |    2 +-
 src/mesa/main/eval.c                              |   16 ++++++++--------
 src/mesa/main/teximage.c                          |    2 +-
 src/mesa/program/nvfragparse.c                    |    2 +-
 src/mesa/program/nvvertparse.c                    |    2 +-
 src/mesa/swrast/s_context.c                       |    2 +-
 src/mesa/swrast/s_texcombine.c                    |    2 +-
 src/mesa/tnl/t_vb_fog.c                           |    2 +-
 src/mesa/tnl/t_vb_light.c                         |    2 +-
 src/mesa/tnl/t_vb_texgen.c                        |    4 ++--
 src/mesa/vbo/vbo_save_api.c                       |    2 +-
 19 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/src/gallium/state_trackers/glx/xlib/glx_usefont.c b/src/gallium/state_trackers/glx/xlib/glx_usefont.c
index fa5c93a..5dac7a7 100644
--- a/src/gallium/state_trackers/glx/xlib/glx_usefont.c
+++ b/src/gallium/state_trackers/glx/xlib/glx_usefont.c
@@ -241,7 +241,7 @@ glXUseXFont(Font font, int first, int count, int listbase)
    max_bm_width = (max_width + 7) / 8;
    max_bm_height = max_height;
 
-   bm = (GLubyte *) MALLOC((max_bm_width * max_bm_height) * sizeof(GLubyte));
+   bm = (GLubyte *) malloc((max_bm_width * max_bm_height) * sizeof(GLubyte));
    if (!bm) {
       XFreeFontInfo(NULL, fs, 1);
       _mesa_error(NULL, GL_OUT_OF_MEMORY,
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c
index 8f90704..ef275b2 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
@@ -220,7 +220,7 @@ bits_per_pixel( XMesaVisual xmv )
    /* Create a temporary XImage */
    img = XCreateImage( dpy, visinfo->visual, visinfo->depth,
 		       ZPixmap, 0,           /*format, offset*/
-		       (char*) MALLOC(8),    /*data*/
+		       (char*) malloc(8),    /*data*/
 		       1, 1,                 /*width, height*/
 		       32,                   /*bitmap_pad*/
 		       0                     /*bytes_per_line*/
@@ -706,7 +706,7 @@ XMesaVisual XMesaCreateVisual( Display *display,
     * the struct but we may need some of the information contained in it
     * at a later time.
     */
-   v->visinfo = (XVisualInfo *) MALLOC(sizeof(*visinfo));
+   v->visinfo = (XVisualInfo *) malloc(sizeof(*visinfo));
    if (!v->visinfo) {
       free(v);
       return NULL;
diff --git a/src/mesa/drivers/dri/common/xmlconfig.c b/src/mesa/drivers/dri/common/xmlconfig.c
index 6d1d5ec..bbd62f7 100644
--- a/src/mesa/drivers/dri/common/xmlconfig.c
+++ b/src/mesa/drivers/dri/common/xmlconfig.c
@@ -142,10 +142,10 @@ static GLuint countOptions (const driOptionCache *cache) {
     return count;
 }
 
-/** \brief Like strdup but using MALLOC and with error checking. */
+/** \brief Like strdup but using malloc and with error checking. */
 #define XSTRDUP(dest,source) do { \
     GLuint len = strlen (source); \
-    if (!(dest = MALLOC (len+1))) { \
+    if (!(dest = malloc(len+1))) { \
 	fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__); \
 	abort(); \
     } \
@@ -347,7 +347,7 @@ static GLboolean parseRanges (driOptionInfo *info, const XML_Char *string) {
 	if (*range == ',')
 	    ++nRanges;
 
-    if ((ranges = MALLOC (nRanges*sizeof(driOptionRange))) == NULL) {
+    if ((ranges = malloc(nRanges*sizeof(driOptionRange))) == NULL) {
 	fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__);
 	abort();
     }
@@ -702,8 +702,8 @@ void driParseOptionInfo (driOptionCache *info,
     GLuint size, log2size;
     for (size = 1, log2size = 0; size < minSize; size <<= 1, ++log2size);
     info->tableSize = log2size;
-    info->info = CALLOC (size * sizeof (driOptionInfo));
-    info->values = CALLOC (size * sizeof (driOptionValue));
+    info->info = calloc(size, sizeof (driOptionInfo));
+    info->values = calloc(size, sizeof (driOptionValue));
     if (info->info == NULL || info->values == NULL) {
 	fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__);
 	abort();
@@ -895,7 +895,7 @@ static void optConfEndElem (void *userData, const XML_Char *name) {
 static void initOptionCache (driOptionCache *cache, const driOptionCache *info) {
     cache->info = info->info;
     cache->tableSize = info->tableSize;
-    cache->values = MALLOC ((1<<info->tableSize) * sizeof (driOptionValue));
+    cache->values = malloc((1<<info->tableSize) * sizeof (driOptionValue));
     if (cache->values == NULL) {
 	fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__);
 	abort();
@@ -959,7 +959,7 @@ void driParseConfigFiles (driOptionCache *cache, const driOptionCache *info,
 
     if ((home = getenv ("HOME"))) {
 	GLuint len = strlen (home);
-	filenames[1] = MALLOC (len + 7+1);
+	filenames[1] = malloc(len + 7+1);
 	if (filenames[1] == NULL)
 	    __driUtilMessage ("Can't allocate memory for %s/.drirc.", home);
 	else {
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c
index 1782714..1d7db52 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c
@@ -90,7 +90,7 @@ nouveau_bufferobj_data(struct gl_context *ctx, GLenum target, GLsizeiptrARB size
 	    (size < 512 && usage == GL_DYNAMIC_DRAW_ARB) ||
 	    context_chipset(ctx) < 0x10) {
 		/* Heuristic: keep it in system ram */
-		nbo->sys = MALLOC(size);
+		nbo->sys = malloc(size);
 
 	} else {
 		/* Get a hardware BO */
diff --git a/src/mesa/drivers/x11/xfonts.c b/src/mesa/drivers/x11/xfonts.c
index 91f819b..ac275bb 100644
--- a/src/mesa/drivers/x11/xfonts.c
+++ b/src/mesa/drivers/x11/xfonts.c
@@ -247,7 +247,7 @@ Fake_glXUseXFont(Font font, int first, int count, int listbase)
    max_bm_width = (max_width + 7) / 8;
    max_bm_height = max_height;
 
-   bm = (GLubyte *) MALLOC((max_bm_width * max_bm_height) * sizeof(GLubyte));
+   bm = (GLubyte *) malloc((max_bm_width * max_bm_height) * sizeof(GLubyte));
    if (!bm) {
       XFreeFontInfo(NULL, fs, 1);
       _mesa_error(NULL, GL_OUT_OF_MEMORY,
diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c
index 249bbdf..6696f70 100644
--- a/src/mesa/drivers/x11/xm_api.c
+++ b/src/mesa/drivers/x11/xm_api.c
@@ -171,7 +171,7 @@ bits_per_pixel( XMesaVisual xmv )
    /* Create a temporary XImage */
    img = XCreateImage( dpy, visinfo->visual, visinfo->depth,
 		       ZPixmap, 0,           /*format, offset*/
-		       (char*) MALLOC(8),    /*data*/
+		       (char*) malloc(8),    /*data*/
 		       1, 1,                 /*width, height*/
 		       32,                   /*bitmap_pad*/
 		       0                     /*bytes_per_line*/
@@ -781,7 +781,7 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
     * the struct but we may need some of the information contained in it
     * at a later time.
     */
-   v->visinfo = (XVisualInfo *) MALLOC(sizeof(*visinfo));
+   v->visinfo = (XVisualInfo *) malloc(sizeof(*visinfo));
    if(!v->visinfo) {
       free(v);
       return NULL;
diff --git a/src/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c
index eb68f94..242b6de 100644
--- a/src/mesa/drivers/x11/xm_buffer.c
+++ b/src/mesa/drivers/x11/xm_buffer.c
@@ -203,7 +203,7 @@ alloc_back_buffer(XMesaBuffer b, GLuint width, GLuint height)
 	    _mesa_warning(NULL, "alloc_back_buffer: XCreateImage failed.\n");
             return;
 	 }
-         b->backxrb->ximage->data = (char *) MALLOC(b->backxrb->ximage->height
+         b->backxrb->ximage->data = (char *) malloc(b->backxrb->ximage->height
                                         * b->backxrb->ximage->bytes_per_line);
          if (!b->backxrb->ximage->data) {
             _mesa_warning(NULL, "alloc_back_buffer: MALLOC failed.\n");
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 8cb2a68..6b0a76a 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -398,7 +398,7 @@ _mesa_PushAttrib(GLbitfield mask)
 
    if (mask & GL_POLYGON_STIPPLE_BIT) {
       GLuint *stipple;
-      stipple = (GLuint *) MALLOC( 32*sizeof(GLuint) );
+      stipple = (GLuint *) malloc( 32*sizeof(GLuint) );
       memcpy( stipple, ctx->PolygonStipple, 32*sizeof(GLuint) );
       save_attrib_data(&head, GL_POLYGON_STIPPLE_BIT, stipple);
    }
diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c
index 8b96319..950cc4f 100644
--- a/src/mesa/main/errors.c
+++ b/src/mesa/main/errors.c
@@ -322,7 +322,7 @@ _mesa_log_msg(struct gl_context *ctx, GLenum source, GLenum type,
 
    assert(!emptySlot->message && !emptySlot->length);
 
-   emptySlot->message = MALLOC(len+1);
+   emptySlot->message = malloc(len+1);
    if (emptySlot->message) {
       (void) strncpy(emptySlot->message, buf, (size_t)len);
       emptySlot->message[len] = '\0';
diff --git a/src/mesa/main/eval.c b/src/mesa/main/eval.c
index e651715..348b7ac 100644
--- a/src/mesa/main/eval.c
+++ b/src/mesa/main/eval.c
@@ -218,7 +218,7 @@ GLfloat *_mesa_copy_map_points1f( GLenum target, GLint ustride, GLint uorder,
    if (!points || !size)
       return NULL;
 
-   buffer = (GLfloat *) MALLOC(uorder * size * sizeof(GLfloat));
+   buffer = (GLfloat *) 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 = (GLfloat *) 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 = (GLfloat *) malloc((uorder*vorder*size+hsize)*sizeof(GLfloat));
    else
-     buffer = (GLfloat *) MALLOC((uorder*vorder*size+dsize)*sizeof(GLfloat));
+     buffer = (GLfloat *) 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 = (GLfloat *) malloc((uorder*vorder*size+hsize)*sizeof(GLfloat));
    else
-     buffer = (GLfloat *) MALLOC((uorder*vorder*size+dsize)*sizeof(GLfloat));
+     buffer = (GLfloat *) 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 = (GLfloat *) 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 = (GLfloat *) malloc(n * sizeof(GLfloat));
    if (map->Points) {
       GLint i;
       for (i=0;i<n;i++)
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 11b1b30..cdb0905 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1015,7 +1015,7 @@ make_null_texture(GLint width, GLint height, GLint depth, GLenum format)
 {
    const GLint components = _mesa_components_in_format(format);
    const GLint numPixels = width * height * depth;
-   GLubyte *data = (GLubyte *) MALLOC(numPixels * components * sizeof(GLubyte));
+   GLubyte *data = (GLubyte *) malloc(numPixels * components * sizeof(GLubyte));
 
 #ifdef DEBUG
    /*
diff --git a/src/mesa/program/nvfragparse.c b/src/mesa/program/nvfragparse.c
index 20c8579..150e231 100644
--- a/src/mesa/program/nvfragparse.c
+++ b/src/mesa/program/nvfragparse.c
@@ -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 = (GLubyte *) malloc(len + 1);
    if (!programString) {
       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
       return;
diff --git a/src/mesa/program/nvvertparse.c b/src/mesa/program/nvvertparse.c
index 7b46bef..62b27b9 100644
--- a/src/mesa/program/nvvertparse.c
+++ b/src/mesa/program/nvvertparse.c
@@ -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 = (GLubyte *) malloc(len + 1);
    if (!programString) {
       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
       return;
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index 4ed7b94..238f923 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -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 = (SWspanarrays *) malloc(maxThreads * sizeof(SWspanarrays));
    if (!swrast->SpanArrays) {
       FREE(swrast);
       return GL_FALSE;
diff --git a/src/mesa/swrast/s_texcombine.c b/src/mesa/swrast/s_texcombine.c
index 2a32361..9c745d1 100644
--- a/src/mesa/swrast/s_texcombine.c
+++ b/src/mesa/swrast/s_texcombine.c
@@ -611,7 +611,7 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span )
        * thread.
        */
       swrast->TexelBuffer =
-	 (GLfloat *) MALLOC(ctx->Const.MaxTextureImageUnits * maxThreads *
+	 (GLfloat *) malloc(ctx->Const.MaxTextureImageUnits * maxThreads *
 			    SWRAST_MAX_WIDTH * 4 * sizeof(GLfloat));
       if (!swrast->TexelBuffer) {
 	 _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture_combine");
diff --git a/src/mesa/tnl/t_vb_fog.c b/src/mesa/tnl/t_vb_fog.c
index cbd8dfc..cd692dd 100644
--- a/src/mesa/tnl/t_vb_fog.c
+++ b/src/mesa/tnl/t_vb_fog.c
@@ -239,7 +239,7 @@ alloc_fog_data(struct gl_context *ctx, struct tnl_pipeline_stage *stage)
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    struct fog_stage_data *store;
-   stage->privatePtr = MALLOC(sizeof(*store));
+   stage->privatePtr = malloc(sizeof(*store));
    store = FOG_STAGE_DATA(stage);
    if (!store)
       return GL_FALSE;
diff --git a/src/mesa/tnl/t_vb_light.c b/src/mesa/tnl/t_vb_light.c
index 854887c..a992ea7 100644
--- a/src/mesa/tnl/t_vb_light.c
+++ b/src/mesa/tnl/t_vb_light.c
@@ -421,7 +421,7 @@ static GLboolean init_lighting( struct gl_context *ctx,
    struct light_stage_data *store;
    GLuint size = tnl->vb.Size;
 
-   stage->privatePtr = MALLOC(sizeof(*store));
+   stage->privatePtr = malloc(sizeof(*store));
    store = LIGHT_STAGE_DATA(stage);
    if (!store)
       return GL_FALSE;
diff --git a/src/mesa/tnl/t_vb_texgen.c b/src/mesa/tnl/t_vb_texgen.c
index d4c7885..1b4de30 100644
--- a/src/mesa/tnl/t_vb_texgen.c
+++ b/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 = (GLfloat (*)[3]) malloc(VB->Size * sizeof(GLfloat) * 3);
+   store->tmp_m = (GLfloat *) malloc(VB->Size * sizeof(GLfloat));
 
    return GL_TRUE;
 }
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index a02a13d..bebda7a 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -353,7 +353,7 @@ _save_compile_vertex_list(struct gl_context *ctx)
          /* If the malloc fails, we just pull the data out of the VBO
           * later instead.
           */
-         node->current_data = MALLOC(node->current_size * sizeof(GLfloat));
+         node->current_data = malloc(node->current_size * sizeof(GLfloat));
          if (node->current_data) {
             const char *buffer = (const char *) save->vertex_store->buffer;
             unsigned attr_offset = node->attrsz[0] * sizeof(GLfloat);
-- 
1.7.4.1



More information about the mesa-dev mailing list