[Mesa-dev] [PATCH 2/4] replace malloc/free with debug MACROS
marvin24 at gmx.de
marvin24 at gmx.de
Sat Jun 12 13:13:33 PDT 2010
---
src/mesa/drivers/dri/r600/r600_cmdbuf.c | 32 ++++++++++----------
src/mesa/drivers/dri/r600/r700_oglprog.c | 2 +-
src/mesa/drivers/dri/r600/r700_vertprog.c | 2 +-
src/mesa/drivers/dri/radeon/radeon_bo_legacy.c | 20 ++++++------
.../drivers/dri/radeon/radeon_buffer_objects.c | 2 +-
src/mesa/drivers/dri/radeon/radeon_cs_legacy.c | 22 +++++++-------
src/mesa/drivers/dri/radeon/radeon_fbo.c | 4 +-
src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c | 14 ++++----
src/mesa/drivers/dri/radeon/radeon_queryobj.c | 4 +-
src/mesa/drivers/dri/radeon/radeon_screen.c | 4 +-
src/mesa/drivers/dri/radeon/radeon_texture.c | 4 +-
11 files changed, 55 insertions(+), 55 deletions(-)
diff --git a/src/mesa/drivers/dri/r600/r600_cmdbuf.c b/src/mesa/drivers/dri/r600/r600_cmdbuf.c
index afe2d55..d2b59ab 100644
--- a/src/mesa/drivers/dri/r600/r600_cmdbuf.c
+++ b/src/mesa/drivers/dri/r600/r600_cmdbuf.c
@@ -77,15 +77,15 @@ static struct radeon_cs_int *r600_cs_create(struct radeon_cs_manager *csm,
{
struct radeon_cs_int *csi;
- csi = (struct radeon_cs_int*)calloc(1, sizeof(struct radeon_cs_int));
+ csi = (struct radeon_cs_int*)CALLOC_STRUCT(radeon_cs_int);
if (csi == NULL) {
return NULL;
}
csi->csm = csm;
csi->ndw = (ndw + 0x3FF) & (~0x3FF);
- csi->packets = (uint32_t*)malloc(4*csi->ndw);
+ csi->packets = (uint32_t*)MALLOC(4*csi->ndw);
if (csi->packets == NULL) {
- free(csi);
+ FREE(csi);
return NULL;
}
csi->relocs_total_size = 0;
@@ -167,8 +167,8 @@ static int r600_cs_write_reloc(struct radeon_cs_int *csi,
relocs[csi->crelocs].base.read_domain = read_domain;
relocs[csi->crelocs].base.write_domain = write_domain;
relocs[csi->crelocs].base.flags = flags;
- relocs[csi->crelocs].indices = (uint32_t*)malloc(4);
- relocs[csi->crelocs].reloc_indices = (uint32_t*)malloc(4);
+ relocs[csi->crelocs].indices = (uint32_t*)MALLOC(4);
+ relocs[csi->crelocs].reloc_indices = (uint32_t*)MALLOC(4);
if ( (relocs[csi->crelocs].indices == NULL) || (relocs[csi->crelocs].reloc_indices == NULL) )
{
return -ENOMEM;
@@ -346,11 +346,11 @@ static int r600_cs_emit(struct radeon_cs_int *csi)
csm->pending_count = 1;
- reloc_chunk = (uint32_t*)calloc(1, csi->crelocs * 4 * 4);
+ reloc_chunk = (uint32_t*)CALLOC(csi->crelocs * 4 * 4);
r = r600_cs_process_relocs(csi, reloc_chunk, &length_dw_reloc_chunk);
if (r) {
- free(reloc_chunk);
+ FREE(reloc_chunk);
return 0;
}
@@ -380,7 +380,7 @@ static int r600_cs_emit(struct radeon_cs_int *csi)
} while (r == -EAGAIN && retry < 1000);
if (r) {
- free(reloc_chunk);
+ FREE(reloc_chunk);
return r;
}
@@ -392,7 +392,7 @@ static int r600_cs_emit(struct radeon_cs_int *csi)
csi->csm->vram_write_used = 0;
csi->csm->gart_write_used = 0;
- free(reloc_chunk);
+ FREE(reloc_chunk);
return 0;
}
@@ -405,24 +405,24 @@ static void inline r600_cs_free_reloc(void *relocs_p, int crelocs)
return;
for (i = 0; i < crelocs; i++)
{
- free(relocs[i].indices);
- free(relocs[i].reloc_indices);
+ FREE(relocs[i].indices);
+ FREE(relocs[i].reloc_indices);
}
}
static int r600_cs_destroy(struct radeon_cs_int *csi)
{
r600_cs_free_reloc(csi->relocs, csi->crelocs);
- free(csi->relocs);
- free(csi->packets);
- free(csi);
+ FREE(csi->relocs);
+ FREE(csi->packets);
+ FREE(csi);
return 0;
}
static int r600_cs_erase(struct radeon_cs_int *csi)
{
r600_cs_free_reloc(csi->relocs, csi->crelocs);
- free(csi->relocs);
+ FREE(csi->relocs);
csi->relocs_total_size = 0;
csi->relocs = NULL;
csi->crelocs = 0;
@@ -458,7 +458,7 @@ struct radeon_cs_manager * r600_radeon_cs_manager_legacy_ctor(struct radeon_cont
struct r600_cs_manager_legacy *csm;
csm = (struct r600_cs_manager_legacy*)
- calloc(1, sizeof(struct r600_cs_manager_legacy));
+ CALLOC_STRUCT(r600_cs_manager_legacy);
if (csm == NULL) {
return NULL;
}
diff --git a/src/mesa/drivers/dri/r600/r700_oglprog.c b/src/mesa/drivers/dri/r600/r700_oglprog.c
index b7124e6..d0697e9 100644
--- a/src/mesa/drivers/dri/r600/r700_oglprog.c
+++ b/src/mesa/drivers/dri/r600/r700_oglprog.c
@@ -53,7 +53,7 @@ static void freeVertProgCache(GLcontext *ctx, struct r700_vertex_program_cont *c
Clean_Up_Shader(&(vp->r700Shader));
_mesa_reference_vertprog(ctx, &vp->mesa_program, NULL);
- free(vp);
+ FREE(vp);
vp = tmp;
}
}
diff --git a/src/mesa/drivers/dri/r600/r700_vertprog.c b/src/mesa/drivers/dri/r600/r700_vertprog.c
index 14dd2a5..f8dff2e 100644
--- a/src/mesa/drivers/dri/r600/r700_vertprog.c
+++ b/src/mesa/drivers/dri/r600/r700_vertprog.c
@@ -307,7 +307,7 @@ struct r700_vertex_program* r700TranslateVertexShader(GLcontext *ctx,
struct r700_vertex_program *vp;
unsigned int i;
- vp = calloc(1, sizeof(*vp));
+ vp = CALLOC(sizeof(*vp));
vp->mesa_program = _mesa_clone_vertex_program(ctx, mesa_vp);
if (mesa_vp->IsPositionInvariant)
diff --git a/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c b/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c
index 78f73bf..02eff1c 100644
--- a/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c
+++ b/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c
@@ -303,7 +303,7 @@ static struct bo_legacy *bo_allocate(struct bo_manager_legacy *boml,
size = (size + pgsize) & ~pgsize;
- bo_legacy = (struct bo_legacy*)calloc(1, sizeof(struct bo_legacy));
+ bo_legacy = (struct bo_legacy*)CALLOC_STRUCT(bo_legacy);
if (bo_legacy == NULL) {
return NULL;
}
@@ -412,11 +412,11 @@ static void bo_free(struct bo_legacy *bo_legacy)
driDestroyTextureObject(&bo_legacy->tobj->base);
bo_legacy->tobj = NULL;
/* free backing store */
- free(bo_legacy->ptr);
+ FREE(bo_legacy->ptr);
}
}
memset(bo_legacy, 0 , sizeof(struct bo_legacy));
- free(bo_legacy);
+ FREE(bo_legacy);
}
static struct radeon_bo *bo_open(struct radeon_bo_manager *bom,
@@ -468,7 +468,7 @@ retry:
}
else
{
- bo_legacy->ptr = malloc(bo_legacy->base.size);
+ bo_legacy->ptr = MALLOC(bo_legacy->base.size);
if (bo_legacy->ptr == NULL) {
bo_free(bo_legacy);
return NULL;
@@ -590,7 +590,7 @@ static int bo_vram_validate(struct radeon_bo_int *bo,
int retry_count = 0, pending_retry = 0;
if (!bo_legacy->tobj) {
- bo_legacy->tobj = CALLOC(sizeof(struct bo_legacy_texture_object));
+ bo_legacy->tobj = CALLOC_STRUCT(bo_legacy_texture_object);
bo_legacy->tobj->parent = bo_legacy;
make_empty_list(&bo_legacy->tobj->base);
bo_legacy->tobj->base.totalSize = bo->size;
@@ -603,7 +603,7 @@ static int bo_vram_validate(struct radeon_bo_int *bo,
legacy_track_pending(&boml->base, 0);
retry_count++;
if (retry_count > 2) {
- free(bo_legacy->tobj);
+ FREE(bo_legacy->tobj);
bo_legacy->tobj = NULL;
fprintf(stderr, "Ouch! vram_validate failed %d\n", r);
return -1;
@@ -785,8 +785,8 @@ void radeon_bo_manager_legacy_dtor(struct radeon_bo_manager *bom)
bo_legacy = next;
}
driDestroyTextureHeap(boml->texture_heap);
- free(boml->free_handles);
- free(boml);
+ FREE(boml->free_handles);
+ FREE(boml);
}
static struct bo_legacy *radeon_legacy_bo_alloc_static(struct bo_manager_legacy *bom,
@@ -817,7 +817,7 @@ struct radeon_bo_manager *radeon_bo_manager_legacy_ctor(struct radeon_screen *sc
unsigned size;
bom = (struct bo_manager_legacy*)
- calloc(1, sizeof(struct bo_manager_legacy));
+ CALLOC_STRUCT(bo_manager_legacy);
if (bom == NULL) {
return NULL;
}
@@ -847,7 +847,7 @@ struct radeon_bo_manager *radeon_bo_manager_legacy_ctor(struct radeon_screen *sc
bom->nhandle = 1;
bom->cfree_handles = 0;
bom->nfree_handles = 0x400;
- bom->free_handles = (uint32_t*)malloc(bom->nfree_handles * 4);
+ bom->free_handles = (uint32_t*)MALLOC(bom->nfree_handles * 4);
if (bom->free_handles == NULL) {
radeon_bo_manager_legacy_dtor((struct radeon_bo_manager*)bom);
return NULL;
diff --git a/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c b/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c
index 0897daf..4cc41fe 100644
--- a/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c
+++ b/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c
@@ -70,7 +70,7 @@ radeonDeleteBufferObject(GLcontext * ctx,
radeon_bo_unref(radeon_obj->bo);
}
- free(radeon_obj);
+ FREE(radeon_obj);
}
diff --git a/src/mesa/drivers/dri/radeon/radeon_cs_legacy.c b/src/mesa/drivers/dri/radeon/radeon_cs_legacy.c
index c2722a4..d6f535b 100644
--- a/src/mesa/drivers/dri/radeon/radeon_cs_legacy.c
+++ b/src/mesa/drivers/dri/radeon/radeon_cs_legacy.c
@@ -64,15 +64,15 @@ static struct radeon_cs_int *cs_create(struct radeon_cs_manager *csm,
{
struct radeon_cs_int *csi;
- csi = (struct radeon_cs_int*)calloc(1, sizeof(struct radeon_cs_int));
+ csi = (struct radeon_cs_int*)CALLOC_STRUCT(radeon_cs_int);
if (csi == NULL) {
return NULL;
}
csi->csm = csm;
csi->ndw = (ndw + 0x3FF) & (~0x3FF);
- csi->packets = (uint32_t*)malloc(4*csi->ndw);
+ csi->packets = (uint32_t*)MALLOC(4*csi->ndw);
if (csi->packets == NULL) {
- free(csi);
+ FREE(csi);
return NULL;
}
csi->relocs_total_size = 0;
@@ -146,7 +146,7 @@ static int cs_write_reloc(struct radeon_cs_int *cs,
relocs[cs->crelocs].base.read_domain = read_domain;
relocs[cs->crelocs].base.write_domain = write_domain;
relocs[cs->crelocs].base.flags = flags;
- relocs[cs->crelocs].indices = (uint32_t*)malloc(4);
+ relocs[cs->crelocs].indices = (uint32_t*)MALLOC(4);
if (relocs[cs->crelocs].indices == NULL) {
return -ENOMEM;
}
@@ -346,22 +346,22 @@ static void inline cs_free_reloc(void *relocs_p, int crelocs)
if (!relocs_p)
return;
for (i = 0; i < crelocs; i++)
- free(relocs[i].indices);
+ FREE(relocs[i].indices);
}
static int cs_destroy(struct radeon_cs_int *cs)
{
cs_free_reloc(cs->relocs, cs->crelocs);
- free(cs->relocs);
- free(cs->packets);
- free(cs);
+ FREE(cs->relocs);
+ FREE(cs->packets);
+ FREE(cs);
return 0;
}
static int cs_erase(struct radeon_cs_int *cs)
{
cs_free_reloc(cs->relocs, cs->crelocs);
- free(cs->relocs);
+ FREE(cs->relocs);
cs->relocs_total_size = 0;
cs->relocs = NULL;
cs->crelocs = 0;
@@ -398,7 +398,7 @@ struct radeon_cs_manager *radeon_cs_manager_legacy_ctor(struct radeon_context *c
struct cs_manager_legacy *csm;
csm = (struct cs_manager_legacy*)
- calloc(1, sizeof(struct cs_manager_legacy));
+ CALLOC_STRUCT(cs_manager_legacy);
if (csm == NULL) {
return NULL;
}
@@ -411,6 +411,6 @@ struct radeon_cs_manager *radeon_cs_manager_legacy_ctor(struct radeon_context *c
void radeon_cs_manager_legacy_dtor(struct radeon_cs_manager *csm)
{
- free(csm);
+ FREE(csm);
}
diff --git a/src/mesa/drivers/dri/radeon/radeon_fbo.c b/src/mesa/drivers/dri/radeon/radeon_fbo.c
index 5174850..333ac1f 100644
--- a/src/mesa/drivers/dri/radeon/radeon_fbo.c
+++ b/src/mesa/drivers/dri/radeon/radeon_fbo.c
@@ -66,7 +66,7 @@ radeon_delete_renderbuffer(struct gl_renderbuffer *rb)
if (rrb && rrb->bo) {
radeon_bo_unref(rrb->bo);
}
- free(rrb);
+ FREE(rrb);
}
static void *
@@ -480,7 +480,7 @@ radeon_wrap_texture(GLcontext * ctx, struct gl_texture_image *texImage)
rrb->base.ClassID = RADEON_RB_CLASS;
if (!radeon_update_wrapper(ctx, rrb, texImage)) {
- free(rrb);
+ FREE(rrb);
return NULL;
}
diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
index 6cd1d87..a869957 100644
--- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
+++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
@@ -273,7 +273,7 @@ void radeon_miptree_unreference(radeon_mipmap_tree **ptr)
mt->refcount--;
if (!mt->refcount) {
radeon_bo_unref(mt->bo);
- free(mt);
+ FREE(mt);
}
*ptr = 0;
@@ -521,8 +521,8 @@ static radeon_mipmap_tree * get_biggest_matching_miptree(radeonTexObj *texObj,
unsigned lastLevel)
{
const unsigned numLevels = lastLevel - firstLevel + 1;
- unsigned *mtSizes = calloc(numLevels, sizeof(unsigned));
- radeon_mipmap_tree **mts = calloc(numLevels, sizeof(radeon_mipmap_tree *));
+ unsigned *mtSizes = CALLOC(numLevels*sizeof(unsigned));
+ radeon_mipmap_tree **mts = CALLOC(numLevels*sizeof(radeon_mipmap_tree *));
unsigned mtCount = 0;
unsigned maxMtIndex = 0;
radeon_mipmap_tree *tmp;
@@ -555,8 +555,8 @@ static radeon_mipmap_tree * get_biggest_matching_miptree(radeonTexObj *texObj,
}
if (mtCount == 0) {
- free(mtSizes);
- free(mts);
+ FREE(mtSizes);
+ FREE(mts);
return NULL;
}
@@ -567,8 +567,8 @@ static radeon_mipmap_tree * get_biggest_matching_miptree(radeonTexObj *texObj,
}
tmp = mts[maxMtIndex];
- free(mtSizes);
- free(mts);
+ FREE(mtSizes);
+ FREE(mts);
return tmp;
}
diff --git a/src/mesa/drivers/dri/radeon/radeon_queryobj.c b/src/mesa/drivers/dri/radeon/radeon_queryobj.c
index ab6d02e..73026f6 100644
--- a/src/mesa/drivers/dri/radeon/radeon_queryobj.c
+++ b/src/mesa/drivers/dri/radeon/radeon_queryobj.c
@@ -83,7 +83,7 @@ static struct gl_query_object * radeonNewQueryObject(GLcontext *ctx, GLuint id)
{
struct radeon_query_object *query;
- query = calloc(1, sizeof(struct radeon_query_object));
+ query = CALLOC_STRUCT(radeon_query_object);
query->Base.Id = id;
query->Base.Result = 0;
@@ -105,7 +105,7 @@ static void radeonDeleteQuery(GLcontext *ctx, struct gl_query_object *q)
radeon_bo_unref(query->bo);
}
- free(query);
+ FREE(query);
}
static void radeonWaitQuery(GLcontext *ctx, struct gl_query_object *q)
diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c
index 4f59511..1ea72d4 100644
--- a/src/mesa/drivers/dri/radeon/radeon_screen.c
+++ b/src/mesa/drivers/dri/radeon/radeon_screen.c
@@ -1248,7 +1248,7 @@ radeonCreateScreen( __DRIscreen *sPriv )
screen->bom = radeon_bo_manager_legacy_ctor(screen);
if (screen->bom == NULL) {
- free(screen);
+ FREE(screen);
return NULL;
}
@@ -1399,7 +1399,7 @@ radeonCreateScreen2(__DRIscreen *sPriv)
screen->driScreen = sPriv;
screen->bom = radeon_bo_manager_gem_ctor(sPriv->fd);
if (screen->bom == NULL) {
- free(screen);
+ FREE(screen);
return NULL;
}
return screen;
diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c
index bcac125..8a2ce57 100644
--- a/src/mesa/drivers/dri/radeon/radeon_texture.c
+++ b/src/mesa/drivers/dri/radeon/radeon_texture.c
@@ -653,7 +653,7 @@ static GLuint * allocate_image_offsets(GLcontext *ctx,
int i;
GLuint *offsets;
- offsets = malloc(depth * sizeof(GLuint)) ;
+ offsets = MALLOC(depth * sizeof(GLuint)) ;
if (!offsets) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTex[Sub]Image");
return NULL;
@@ -752,7 +752,7 @@ static void radeon_store_teximage(GLcontext* ctx, int dims,
}
if (dims == 3) {
- free(dstImageOffsets);
+ FREE(dstImageOffsets);
}
radeon_teximage_unmap(image);
--
1.7.0.4
More information about the mesa-dev
mailing list