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>
_mesa_delete_memory_object(struct gl_context *ctx,
struct gl_memory_object *memObj)
{
- free(memObj);
+ FREE(memObj);
}
struct gl_semaphore_object *semObj)
{
if (semObj != &DummySemaphoreObject)
- free(semObj);
+ FREE(semObj);
}
/**
_mesa_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
{
free(rb->Label);
- free(rb);
+ FREE(rb);
}
static void
#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"
* image storage.
*/
st_FreeTextureImageBuffer( ctx, texImage );
- free(texImage);
+ FREE(texImage);
}
free(texObj->Label);
/* free this object */
- free(texObj);
+ FREE(texObj);
}
#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,
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);
{
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;
_mesa_problem(NULL,
"Unexpected format %s in st_new_renderbuffer_fb",
util_format_name(format));
- free(strb);
+ FREE(strb);
return NULL;
}
#include "main/feedback.h"
#include "main/varray.h"
+#include "util/u_memory.h"
+
#include "vbo/vbo.h"
#include "st_context.h"
static void
feedback_destroy( struct draw_stage *stage )
{
- free(stage);
+ FREE(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;
static void
select_destroy( struct draw_stage *stage )
{
- free(stage);
+ FREE(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;
#include "main/externalobjects.h"
+#include "util/u_memory.h"
#include "st_context.h"
#include "st_cb_memoryobjects.h"
#include "st_util.h"
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;
#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"
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;
free_queries(pipe, stq);
free(stq->base.Label);
- free(stq);
+ FREE(stq);
}
static int
#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"
{
struct rastpos_stage *rstage = (struct rastpos_stage*)stage;
_mesa_reference_vao(rstage->ctx, &rstage->VAO, NULL);
- free(stage);
+ FREE(stage);
}
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;
#include "main/externalobjects.h"
+#include "util/u_memory.h"
+
#include "st_context.h"
#include "st_texture.h"
#include "st_util.h"
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;
#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"
{
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);
}
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;
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;
}
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,
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);
if (st->pipe && destroy_pipe)
st->pipe->destroy(st->pipe);
- free(st);
+ FREE(st);
}
{
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();
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