mesa/st: get rid of ST_CALLOC_STRUCT use CALLOC_STRUCT
authorDave Airlie <airlied@redhat.com>
Wed, 29 Dec 2021 00:34:45 +0000 (10:34 +1000)
committerMarge Bot <emma+marge@anholt.net>
Tue, 18 Jan 2022 22:20:18 +0000 (22:20 +0000)
Just tie in the CALLOC_STRUCT/FREE mechanism.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14325>

13 files changed:
src/mesa/main/externalobjects.c
src/mesa/main/renderbuffer.c
src/mesa/main/teximage.c
src/mesa/main/texobj.c
src/mesa/state_tracker/st_cb_fbo.c
src/mesa/state_tracker/st_cb_feedback.c
src/mesa/state_tracker/st_cb_memoryobjects.c
src/mesa/state_tracker/st_cb_queryobj.c
src/mesa/state_tracker/st_cb_rasterpos.c
src/mesa/state_tracker/st_cb_semaphoreobjects.c
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_context.c
src/mesa/state_tracker/st_util.h

index ebacb05..2d8391f 100644 (file)
@@ -45,7 +45,7 @@ void
 _mesa_delete_memory_object(struct gl_context *ctx,
                            struct gl_memory_object *memObj)
 {
-   free(memObj);
+   FREE(memObj);
 }
 
 
@@ -569,7 +569,7 @@ _mesa_delete_semaphore_object(struct gl_context *ctx,
                               struct gl_semaphore_object *semObj)
 {
    if (semObj != &DummySemaphoreObject)
-      free(semObj);
+      FREE(semObj);
 }
 
 /**
index 196ff0f..cfa0f66 100644 (file)
@@ -85,7 +85,7 @@ void
 _mesa_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
 {
    free(rb->Label);
-   free(rb);
+   FREE(rb);
 }
 
 static void
index f0ce216..82fbd31 100644 (file)
@@ -58,6 +58,8 @@
 #include "pbo.h"
 #include "api_exec_decl.h"
 
+#include "util/u_memory.h"
+
 #include "state_tracker/st_cb_texture.h"
 #include "state_tracker/st_context.h"
 #include "state_tracker/st_format.h"
@@ -219,7 +221,7 @@ _mesa_delete_texture_image(struct gl_context *ctx,
     * image storage.
     */
    st_FreeTextureImageBuffer( ctx, texImage );
-   free(texImage);
+   FREE(texImage);
 }
 
 
index 065da7e..7082a84 100644 (file)
@@ -472,7 +472,7 @@ _mesa_delete_texture_object(struct gl_context *ctx,
    free(texObj->Label);
 
    /* free this object */
-   free(texObj);
+   FREE(texObj);
 }
 
 
index 2c101b8..4ee761d 100644 (file)
@@ -59,7 +59,7 @@
 #include "util/format/u_format.h"
 #include "util/u_inlines.h"
 #include "util/u_surface.h"
-
+#include "util/u_memory.h"
 
 static GLboolean
 st_renderbuffer_alloc_sw_storage(struct gl_context * ctx,
@@ -303,7 +303,7 @@ st_renderbuffer_delete(struct gl_context *ctx, struct gl_renderbuffer *rb)
 struct gl_renderbuffer *
 st_new_renderbuffer(struct gl_context *ctx, GLuint name)
 {
-   struct st_renderbuffer *strb = ST_CALLOC_STRUCT(st_renderbuffer);
+   struct st_renderbuffer *strb = CALLOC_STRUCT(st_renderbuffer);
    if (strb) {
       assert(name != 0);
       _mesa_init_renderbuffer(&strb->Base, name);
@@ -324,7 +324,7 @@ st_new_renderbuffer_fb(enum pipe_format format, unsigned samples, boolean sw)
 {
    struct st_renderbuffer *strb;
 
-   strb = ST_CALLOC_STRUCT(st_renderbuffer);
+   strb = CALLOC_STRUCT(st_renderbuffer);
    if (!strb) {
       _mesa_error(NULL, GL_OUT_OF_MEMORY, "creating renderbuffer");
       return NULL;
@@ -433,7 +433,7 @@ st_new_renderbuffer_fb(enum pipe_format format, unsigned samples, boolean sw)
       _mesa_problem(NULL,
                     "Unexpected format %s in st_new_renderbuffer_fb",
                     util_format_name(format));
-      free(strb);
+      FREE(strb);
       return NULL;
    }
 
index 78000b5..e7db3da 100644 (file)
@@ -42,6 +42,8 @@
 #include "main/feedback.h"
 #include "main/varray.h"
 
+#include "util/u_memory.h"
+
 #include "vbo/vbo.h"
 
 #include "st_context.h"
@@ -176,7 +178,7 @@ feedback_reset_stipple_counter( struct draw_stage *stage )
 static void
 feedback_destroy( struct draw_stage *stage )
 {
-   free(stage);
+   FREE(stage);
 }
 
 /**
@@ -185,7 +187,7 @@ feedback_destroy( struct draw_stage *stage )
 static struct draw_stage *
 draw_glfeedback_stage(struct gl_context *ctx, struct draw_context *draw)
 {
-   struct feedback_stage *fs = ST_CALLOC_STRUCT(feedback_stage);
+   struct feedback_stage *fs = CALLOC_STRUCT(feedback_stage);
 
    fs->stage.draw = draw;
    fs->stage.next = NULL;
@@ -248,7 +250,7 @@ select_reset_stipple_counter( struct draw_stage *stage )
 static void
 select_destroy( struct draw_stage *stage )
 {
-   free(stage);
+   FREE(stage);
 }
 
 
@@ -258,7 +260,7 @@ select_destroy( struct draw_stage *stage )
 static struct draw_stage *
 draw_glselect_stage(struct gl_context *ctx, struct draw_context *draw)
 {
-   struct feedback_stage *fs = ST_CALLOC_STRUCT(feedback_stage);
+   struct feedback_stage *fs = CALLOC_STRUCT(feedback_stage);
 
    fs->stage.draw = draw;
    fs->stage.next = NULL;
index 2aa3d83..e826e4c 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "main/externalobjects.h"
 
+#include "util/u_memory.h"
 #include "st_context.h"
 #include "st_cb_memoryobjects.h"
 #include "st_util.h"
@@ -42,7 +43,7 @@
 struct gl_memory_object *
 st_memoryobj_alloc(struct gl_context *ctx, GLuint name)
 {
-   struct st_memory_object *st_obj = ST_CALLOC_STRUCT(st_memory_object);
+   struct st_memory_object *st_obj = CALLOC_STRUCT(st_memory_object);
    if (!st_obj)
       return NULL;
 
index 72714e2..4f96393 100644 (file)
@@ -41,6 +41,7 @@
 #include "pipe/p_defines.h"
 #include "pipe/p_screen.h"
 #include "util/u_inlines.h"
+#include "util/u_memory.h"
 #include "st_context.h"
 #include "st_cb_queryobj.h"
 #include "st_cb_bitmap.h"
@@ -50,7 +51,7 @@
 struct gl_query_object *
 st_NewQueryObject(struct gl_context *ctx, GLuint id)
 {
-   struct st_query_object *stq = ST_CALLOC_STRUCT(st_query_object);
+   struct st_query_object *stq = CALLOC_STRUCT(st_query_object);
    if (stq) {
       stq->base.Id = id;
       stq->base.Ready = GL_TRUE;
@@ -85,7 +86,7 @@ st_DeleteQuery(struct gl_context *ctx, struct gl_query_object *q)
 
    free_queries(pipe, stq);
    free(stq->base.Label);
-   free(stq);
+   FREE(stq);
 }
 
 static int
index 4319b3a..bd66c76 100644 (file)
@@ -44,6 +44,8 @@
 #include "main/state.h"
 #include "main/varray.h"
 
+#include "util/u_memory.h"
+
 #include "st_context.h"
 #include "st_atom.h"
 #include "st_draw.h"
@@ -106,7 +108,7 @@ rastpos_destroy(struct draw_stage *stage)
 {
    struct rastpos_stage *rstage = (struct rastpos_stage*)stage;
    _mesa_reference_vao(rstage->ctx, &rstage->VAO, NULL);
-   free(stage);
+   FREE(stage);
 }
 
 
@@ -187,7 +189,7 @@ rastpos_point(struct draw_stage *stage, struct prim_header *prim)
 static struct rastpos_stage *
 new_draw_rastpos_stage(struct gl_context *ctx, struct draw_context *draw)
 {
-   struct rastpos_stage *rs = ST_CALLOC_STRUCT(rastpos_stage);
+   struct rastpos_stage *rs = CALLOC_STRUCT(rastpos_stage);
 
    rs->stage.draw = draw;
    rs->stage.next = NULL;
index 7b433a9..419ac6a 100644 (file)
@@ -27,6 +27,8 @@
 
 #include "main/externalobjects.h"
 
+#include "util/u_memory.h"
+
 #include "st_context.h"
 #include "st_texture.h"
 #include "st_util.h"
@@ -40,7 +42,7 @@
 struct gl_semaphore_object *
 st_semaphoreobj_alloc(struct gl_context *ctx, GLuint name)
 {
-   struct st_semaphore_object *st_obj = ST_CALLOC_STRUCT(st_semaphore_object);
+   struct st_semaphore_object *st_obj = CALLOC_STRUCT(st_semaphore_object);
    if (!st_obj)
       return NULL;
 
index fa5f4a6..1a95e09 100644 (file)
@@ -76,6 +76,7 @@
 #include "util/u_sampler.h"
 #include "util/u_math.h"
 #include "util/u_box.h"
+#include "util/u_memory.h"
 #include "util/u_simple_shaders.h"
 #include "cso_cache/cso_context.h"
 #include "tgsi/tgsi_ureg.h"
@@ -391,7 +392,7 @@ st_NewTextureImage(struct gl_context * ctx)
 {
    DBG("%s\n", __func__);
    (void) ctx;
-   return (struct gl_texture_image *) ST_CALLOC_STRUCT(st_texture_image);
+   return (struct gl_texture_image *) CALLOC_STRUCT(st_texture_image);
 }
 
 
@@ -406,7 +407,7 @@ st_DeleteTextureImage(struct gl_context * ctx, struct gl_texture_image *img)
 struct gl_texture_object *
 st_NewTextureObject(struct gl_context * ctx, GLuint name, GLenum target)
 {
-   struct st_texture_object *obj = ST_CALLOC_STRUCT(st_texture_object);
+   struct st_texture_object *obj = CALLOC_STRUCT(st_texture_object);
    if (!obj)
       return NULL;
 
@@ -485,7 +486,7 @@ st_FreeTextureImageBuffer(struct gl_context *ctx,
    if (stImage->compressed_data &&
        pipe_reference(&stImage->compressed_data->reference, NULL)) {
       free(stImage->compressed_data->ptr);
-      free(stImage->compressed_data);
+      FREE(stImage->compressed_data);
       stImage->compressed_data = NULL;
    }
 
@@ -536,7 +537,7 @@ compressed_tex_fallback_allocate(struct st_context *st,
    if (stImage->compressed_data &&
        pipe_reference(&stImage->compressed_data->reference, NULL)) {
       free(stImage->compressed_data->ptr);
-      free(stImage->compressed_data);
+      FREE(stImage->compressed_data);
    }
 
    unsigned data_size = _mesa_format_image_size(texImage->TexFormat,
@@ -544,7 +545,7 @@ compressed_tex_fallback_allocate(struct st_context *st,
                                                 texImage->Height2,
                                                 texImage->Depth2);
 
-   stImage->compressed_data = ST_CALLOC_STRUCT(st_compressed_data);
+   stImage->compressed_data = CALLOC_STRUCT(st_compressed_data);
    stImage->compressed_data->ptr =
       malloc(data_size * _mesa_num_tex_faces(texImage->TexObject->Target));
    pipe_reference_init(&stImage->compressed_data->reference, 1);
index c927822..364ffa5 100644 (file)
@@ -438,7 +438,7 @@ st_destroy_context_priv(struct st_context *st, bool destroy_pipe)
    if (st->pipe && destroy_pipe)
       st->pipe->destroy(st->pipe);
 
-   free(st);
+   FREE(st);
 }
 
 
@@ -502,7 +502,7 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
 {
    struct pipe_screen *screen = pipe->screen;
    uint i;
-   struct st_context *st = ST_CALLOC_STRUCT( st_context);
+   struct st_context *st = CALLOC_STRUCT( st_context);
 
    util_cpu_detect();
 
index edb13a1..6bab7d0 100644 (file)
@@ -135,10 +135,6 @@ st_point_size_per_vertex(struct gl_context *ctx)
    return false;
 }
 
-/** clear-alloc a struct-sized object, with casting */
-#define ST_CALLOC_STRUCT(T)   (struct T *) calloc(1, sizeof(struct T))
-
-
 #ifdef __cplusplus
 }
 #endif