mesa: consistantly use mesa memory-functions in gallium state tracker

Use _mesa_malloc(), _mesa_free(), etc everywhere, not malloc(), free(), etc.
Still using CALLOC_STRUCT() at this point.
This commit is contained in:
Brian Paul
2009-02-12 10:08:25 -07:00
parent 19dff5efc1
commit 1a2f4dd876
14 changed files with 37 additions and 37 deletions

View File

@@ -69,7 +69,7 @@ void st_init_atoms( struct st_context *st )
{ {
GLuint i; GLuint i;
st->atoms = malloc(sizeof(atoms)); st->atoms = _mesa_malloc(sizeof(atoms));
st->nr_atoms = sizeof(atoms)/sizeof(*atoms); st->nr_atoms = sizeof(atoms)/sizeof(*atoms);
memcpy(st->atoms, atoms, sizeof(atoms)); memcpy(st->atoms, atoms, sizeof(atoms));
@@ -92,7 +92,7 @@ void st_init_atoms( struct st_context *st )
void st_destroy_atoms( struct st_context *st ) void st_destroy_atoms( struct st_context *st )
{ {
if (st->atoms) { if (st->atoms) {
free(st->atoms); _mesa_free(st->atoms);
st->atoms = NULL; st->atoms = NULL;
} }
} }

View File

@@ -298,7 +298,7 @@ st_free_translated_vertex_programs(struct st_context *st,
while (xvp) { while (xvp) {
next = xvp->next; next = xvp->next;
free(xvp); _mesa_free(xvp);
xvp = next; xvp = next;
} }
} }
@@ -313,7 +313,7 @@ get_passthrough_fs(struct st_context *st)
st->passthrough_fs = st->passthrough_fs =
util_make_fragment_passthrough_shader(st->pipe, &shader); util_make_fragment_passthrough_shader(st->pipe, &shader);
#if 0 /* We actually need to keep the tokens around at this time */ #if 0 /* We actually need to keep the tokens around at this time */
free((void *) shader.tokens); _mesa_free((void *) shader.tokens);
#endif #endif
} }

View File

@@ -206,8 +206,8 @@ accum_accum(struct pipe_context *pipe, GLfloat value,
color_surf = screen->get_tex_surface(screen, color_strb->texture, 0, 0, 0, color_surf = screen->get_tex_surface(screen, color_strb->texture, 0, 0, 0,
PIPE_BUFFER_USAGE_CPU_READ); PIPE_BUFFER_USAGE_CPU_READ);
colorBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); colorBuf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); accBuf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
pipe_get_tile_rgba(color_surf, xpos, ypos, width, height, colorBuf); pipe_get_tile_rgba(color_surf, xpos, ypos, width, height, colorBuf);
acc_get_tile_rgba(pipe, acc_surf, xpos, ypos, width, height, accBuf); acc_get_tile_rgba(pipe, acc_surf, xpos, ypos, width, height, accBuf);
@@ -218,8 +218,8 @@ accum_accum(struct pipe_context *pipe, GLfloat value,
acc_put_tile_rgba(pipe, acc_surf, xpos, ypos, width, height, accBuf); acc_put_tile_rgba(pipe, acc_surf, xpos, ypos, width, height, accBuf);
free(colorBuf); _mesa_free(colorBuf);
free(accBuf); _mesa_free(accBuf);
pipe_surface_reference(&acc_surf, NULL); pipe_surface_reference(&acc_surf, NULL);
pipe_surface_reference(&color_surf, NULL); pipe_surface_reference(&color_surf, NULL);
} }
@@ -242,7 +242,7 @@ accum_load(struct pipe_context *pipe, GLfloat value,
color_surf = screen->get_tex_surface(screen, color_strb->texture, 0, 0, 0, color_surf = screen->get_tex_surface(screen, color_strb->texture, 0, 0, 0,
PIPE_BUFFER_USAGE_CPU_READ); PIPE_BUFFER_USAGE_CPU_READ);
buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); buf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
pipe_get_tile_rgba(color_surf, xpos, ypos, width, height, buf); pipe_get_tile_rgba(color_surf, xpos, ypos, width, height, buf);
@@ -252,7 +252,7 @@ accum_load(struct pipe_context *pipe, GLfloat value,
acc_put_tile_rgba(pipe, acc_surf, xpos, ypos, width, height, buf); acc_put_tile_rgba(pipe, acc_surf, xpos, ypos, width, height, buf);
free(buf); _mesa_free(buf);
pipe_surface_reference(&acc_surf, NULL); pipe_surface_reference(&acc_surf, NULL);
pipe_surface_reference(&color_surf, NULL); pipe_surface_reference(&color_surf, NULL);
} }
@@ -271,7 +271,7 @@ accum_return(GLcontext *ctx, GLfloat value,
GLfloat *abuf, *cbuf = NULL; GLfloat *abuf, *cbuf = NULL;
GLint i, ch; GLint i, ch;
abuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); abuf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
acc_surf = screen->get_tex_surface(screen, acc_strb->texture, 0, 0, 0, acc_surf = screen->get_tex_surface(screen, acc_strb->texture, 0, 0, 0,
PIPE_BUFFER_USAGE_CPU_READ); PIPE_BUFFER_USAGE_CPU_READ);
@@ -283,7 +283,7 @@ accum_return(GLcontext *ctx, GLfloat value,
acc_get_tile_rgba(pipe, acc_surf, xpos, ypos, width, height, abuf); acc_get_tile_rgba(pipe, acc_surf, xpos, ypos, width, height, abuf);
if (!colormask[0] || !colormask[1] || !colormask[2] || !colormask[3]) { if (!colormask[0] || !colormask[1] || !colormask[2] || !colormask[3]) {
cbuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); cbuf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
pipe_get_tile_rgba(color_surf, xpos, ypos, width, height, cbuf); pipe_get_tile_rgba(color_surf, xpos, ypos, width, height, cbuf);
} }
@@ -301,9 +301,9 @@ accum_return(GLcontext *ctx, GLfloat value,
pipe_put_tile_rgba(color_surf, xpos, ypos, width, height, abuf); pipe_put_tile_rgba(color_surf, xpos, ypos, width, height, abuf);
free(abuf); _mesa_free(abuf);
if (cbuf) if (cbuf)
free(cbuf); _mesa_free(cbuf);
pipe_surface_reference(&acc_surf, NULL); pipe_surface_reference(&acc_surf, NULL);
pipe_surface_reference(&color_surf, NULL); pipe_surface_reference(&color_surf, NULL);
} }

View File

@@ -827,7 +827,7 @@ st_destroy_bitmap(struct st_context *st)
if (st->bitmap.cache) { if (st->bitmap.cache) {
pipe_texture_release(&st->bitmap.cache->texture); pipe_texture_release(&st->bitmap.cache->texture);
FREE(st->bitmap.cache); _mesa_free(st->bitmap.cache);
st->bitmap.cache = NULL; st->bitmap.cache = NULL;
} }
} }

View File

@@ -80,7 +80,7 @@ st_bufferobj_free(GLcontext *ctx, struct gl_buffer_object *obj)
if (st_obj->buffer) if (st_obj->buffer)
pipe_buffer_reference(pipe->screen, &st_obj->buffer, NULL); pipe_buffer_reference(pipe->screen, &st_obj->buffer, NULL);
free(st_obj); _mesa_free(st_obj);
} }

View File

@@ -98,12 +98,12 @@ st_destroy_clear(struct st_context *st)
struct pipe_context *pipe = st->pipe; struct pipe_context *pipe = st->pipe;
if (st->clear.vert_shader.tokens) { if (st->clear.vert_shader.tokens) {
FREE((void *) st->clear.vert_shader.tokens); _mesa_free((void *) st->clear.vert_shader.tokens);
st->clear.vert_shader.tokens = NULL; st->clear.vert_shader.tokens = NULL;
} }
if (st->clear.frag_shader.tokens) { if (st->clear.frag_shader.tokens) {
FREE((void *) st->clear.frag_shader.tokens); _mesa_free((void *) st->clear.frag_shader.tokens);
st->clear.frag_shader.tokens = NULL; st->clear.frag_shader.tokens = NULL;
} }

View File

@@ -896,7 +896,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
ubyte *buffer; ubyte *buffer;
int i; int i;
buffer = malloc(width * height * sizeof(ubyte)); buffer = _mesa_malloc(width * height * sizeof(ubyte));
if (!buffer) { if (!buffer) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels(stencil)"); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels(stencil)");
return; return;
@@ -950,7 +950,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
} }
} }
free(buffer); _mesa_free(buffer);
/* unmap the stencil buffer */ /* unmap the stencil buffer */
screen->surface_unmap(screen, psDraw); screen->surface_unmap(screen, psDraw);
@@ -1056,19 +1056,19 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
if (type == GL_COLOR) { if (type == GL_COLOR) {
/* alternate path using get/put_tile() */ /* alternate path using get/put_tile() */
GLfloat *buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); GLfloat *buf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
pipe_get_tile_rgba(psRead, srcx, srcy, width, height, buf); pipe_get_tile_rgba(psRead, srcx, srcy, width, height, buf);
pipe_put_tile_rgba(psTex, 0, 0, width, height, buf); pipe_put_tile_rgba(psTex, 0, 0, width, height, buf);
free(buf); _mesa_free(buf);
} }
else { else {
/* GL_DEPTH */ /* GL_DEPTH */
GLuint *buf = (GLuint *) malloc(width * height * sizeof(GLuint)); GLuint *buf = (GLuint *) _mesa_malloc(width * height * sizeof(GLuint));
pipe_get_tile_z(psRead, srcx, srcy, width, height, buf); pipe_get_tile_z(psRead, srcx, srcy, width, height, buf);
pipe_put_tile_z(psTex, 0, 0, width, height, buf); pipe_put_tile_z(psTex, 0, 0, width, height, buf);
free(buf); _mesa_free(buf);
} }
pipe_surface_reference(&psRead, NULL); pipe_surface_reference(&psRead, NULL);
} }

View File

@@ -194,7 +194,7 @@ st_renderbuffer_delete(struct gl_renderbuffer *rb)
ASSERT(strb); ASSERT(strb);
pipe_surface_reference(&strb->surface, NULL); pipe_surface_reference(&strb->surface, NULL);
pipe_texture_reference(&strb->texture, NULL); pipe_texture_reference(&strb->texture, NULL);
free(strb); _mesa_free(strb);
} }

View File

@@ -152,7 +152,7 @@ st_delete_program(GLcontext *ctx, struct gl_program *prog)
} }
if (stvp->state.tokens) { if (stvp->state.tokens) {
FREE((void *) stvp->state.tokens); _mesa_free((void *) stvp->state.tokens);
stvp->state.tokens = NULL; stvp->state.tokens = NULL;
} }
} }
@@ -167,7 +167,7 @@ st_delete_program(GLcontext *ctx, struct gl_program *prog)
} }
if (stfp->state.tokens) { if (stfp->state.tokens) {
FREE((void *) stfp->state.tokens); _mesa_free((void *) stfp->state.tokens);
stfp->state.tokens = NULL; stfp->state.tokens = NULL;
} }
@@ -214,7 +214,7 @@ static void st_program_string_notify( GLcontext *ctx,
} }
if (stfp->state.tokens) { if (stfp->state.tokens) {
FREE((void *) stfp->state.tokens); _mesa_free((void *) stfp->state.tokens);
stfp->state.tokens = NULL; stfp->state.tokens = NULL;
} }
@@ -242,7 +242,7 @@ static void st_program_string_notify( GLcontext *ctx,
} }
if (stvp->state.tokens) { if (stvp->state.tokens) {
FREE((void *) stvp->state.tokens); _mesa_free((void *) stvp->state.tokens);
stvp->state.tokens = NULL; stvp->state.tokens = NULL;
} }

View File

@@ -87,7 +87,7 @@ st_DeleteQuery(GLcontext *ctx, struct gl_query_object *q)
stq->pq = NULL; stq->pq = NULL;
} }
FREE(stq); _mesa_free(stq);
} }

View File

@@ -102,7 +102,7 @@ rastpos_line( struct draw_stage *stage, struct prim_header *prim )
static void static void
rastpos_destroy(struct draw_stage *stage) rastpos_destroy(struct draw_stage *stage)
{ {
free(stage); _mesa_free(stage);
} }

View File

@@ -217,7 +217,7 @@ static void st_destroy_context_priv( struct st_context *st )
st->default_texture = NULL; st->default_texture = NULL;
} }
free( st ); _mesa_free( st );
} }
@@ -245,7 +245,7 @@ void st_destroy_context( struct st_context *st )
pipe->destroy( pipe ); pipe->destroy( pipe );
free(ctx); _mesa_free(ctx);
} }

View File

@@ -223,7 +223,7 @@ setup_edgeflags(GLcontext *ctx, GLenum primMode, GLint start, GLint count,
if (!stobj) if (!stobj)
return NULL; return NULL;
vec = (unsigned *) calloc(sizeof(unsigned), (count + 31) / 32); vec = (unsigned *) _mesa_calloc(sizeof(unsigned) * ((count + 31) / 32));
if (!vec) if (!vec)
return NULL; return NULL;

View File

@@ -61,9 +61,9 @@
static INLINE void * static INLINE void *
mem_dup(const void *src, uint size) mem_dup(const void *src, uint size)
{ {
void *dup = MALLOC(size); void *dup = _mesa_malloc(size);
if (dup) if (dup)
memcpy(dup, src, size); _mesa_memcpy(dup, src, size);
return dup; return dup;
} }
@@ -307,7 +307,7 @@ st_translate_vertex_program(struct st_context *st,
/* free old shader state, if any */ /* free old shader state, if any */
if (stvp->state.tokens) { if (stvp->state.tokens) {
FREE((void *) stvp->state.tokens); _mesa_free((void *) stvp->state.tokens);
stvp->state.tokens = NULL; stvp->state.tokens = NULL;
} }
if (stvp->driver_shader) { if (stvp->driver_shader) {