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:
@@ -69,7 +69,7 @@ void st_init_atoms( struct st_context *st )
|
||||
{
|
||||
GLuint i;
|
||||
|
||||
st->atoms = malloc(sizeof(atoms));
|
||||
st->atoms = _mesa_malloc(sizeof(atoms));
|
||||
st->nr_atoms = sizeof(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 )
|
||||
{
|
||||
if (st->atoms) {
|
||||
free(st->atoms);
|
||||
_mesa_free(st->atoms);
|
||||
st->atoms = NULL;
|
||||
}
|
||||
}
|
||||
|
@@ -298,7 +298,7 @@ st_free_translated_vertex_programs(struct st_context *st,
|
||||
|
||||
while (xvp) {
|
||||
next = xvp->next;
|
||||
free(xvp);
|
||||
_mesa_free(xvp);
|
||||
xvp = next;
|
||||
}
|
||||
}
|
||||
@@ -313,7 +313,7 @@ get_passthrough_fs(struct st_context *st)
|
||||
st->passthrough_fs =
|
||||
util_make_fragment_passthrough_shader(st->pipe, &shader);
|
||||
#if 0 /* We actually need to keep the tokens around at this time */
|
||||
free((void *) shader.tokens);
|
||||
_mesa_free((void *) shader.tokens);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@@ -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,
|
||||
PIPE_BUFFER_USAGE_CPU_READ);
|
||||
|
||||
colorBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
|
||||
accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
|
||||
colorBuf = (GLfloat *) _mesa_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);
|
||||
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);
|
||||
|
||||
free(colorBuf);
|
||||
free(accBuf);
|
||||
_mesa_free(colorBuf);
|
||||
_mesa_free(accBuf);
|
||||
pipe_surface_reference(&acc_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,
|
||||
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);
|
||||
|
||||
@@ -252,7 +252,7 @@ accum_load(struct pipe_context *pipe, GLfloat value,
|
||||
|
||||
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(&color_surf, NULL);
|
||||
}
|
||||
@@ -271,7 +271,7 @@ accum_return(GLcontext *ctx, GLfloat value,
|
||||
GLfloat *abuf, *cbuf = NULL;
|
||||
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,
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -301,9 +301,9 @@ accum_return(GLcontext *ctx, GLfloat value,
|
||||
|
||||
pipe_put_tile_rgba(color_surf, xpos, ypos, width, height, abuf);
|
||||
|
||||
free(abuf);
|
||||
_mesa_free(abuf);
|
||||
if (cbuf)
|
||||
free(cbuf);
|
||||
_mesa_free(cbuf);
|
||||
pipe_surface_reference(&acc_surf, NULL);
|
||||
pipe_surface_reference(&color_surf, NULL);
|
||||
}
|
||||
|
@@ -827,7 +827,7 @@ st_destroy_bitmap(struct st_context *st)
|
||||
|
||||
if (st->bitmap.cache) {
|
||||
pipe_texture_release(&st->bitmap.cache->texture);
|
||||
FREE(st->bitmap.cache);
|
||||
_mesa_free(st->bitmap.cache);
|
||||
st->bitmap.cache = NULL;
|
||||
}
|
||||
}
|
||||
|
@@ -80,7 +80,7 @@ st_bufferobj_free(GLcontext *ctx, struct gl_buffer_object *obj)
|
||||
if (st_obj->buffer)
|
||||
pipe_buffer_reference(pipe->screen, &st_obj->buffer, NULL);
|
||||
|
||||
free(st_obj);
|
||||
_mesa_free(st_obj);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -98,12 +98,12 @@ st_destroy_clear(struct st_context *st)
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@@ -896,7 +896,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
|
||||
ubyte *buffer;
|
||||
int i;
|
||||
|
||||
buffer = malloc(width * height * sizeof(ubyte));
|
||||
buffer = _mesa_malloc(width * height * sizeof(ubyte));
|
||||
if (!buffer) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels(stencil)");
|
||||
return;
|
||||
@@ -950,7 +950,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
|
||||
}
|
||||
}
|
||||
|
||||
free(buffer);
|
||||
_mesa_free(buffer);
|
||||
|
||||
/* unmap the stencil buffer */
|
||||
screen->surface_unmap(screen, psDraw);
|
||||
@@ -1056,19 +1056,19 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
|
||||
|
||||
if (type == GL_COLOR) {
|
||||
/* 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_put_tile_rgba(psTex, 0, 0, width, height, buf);
|
||||
|
||||
free(buf);
|
||||
_mesa_free(buf);
|
||||
}
|
||||
else {
|
||||
/* 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_put_tile_z(psTex, 0, 0, width, height, buf);
|
||||
free(buf);
|
||||
_mesa_free(buf);
|
||||
}
|
||||
pipe_surface_reference(&psRead, NULL);
|
||||
}
|
||||
|
@@ -194,7 +194,7 @@ st_renderbuffer_delete(struct gl_renderbuffer *rb)
|
||||
ASSERT(strb);
|
||||
pipe_surface_reference(&strb->surface, NULL);
|
||||
pipe_texture_reference(&strb->texture, NULL);
|
||||
free(strb);
|
||||
_mesa_free(strb);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -152,7 +152,7 @@ st_delete_program(GLcontext *ctx, struct gl_program *prog)
|
||||
}
|
||||
|
||||
if (stvp->state.tokens) {
|
||||
FREE((void *) stvp->state.tokens);
|
||||
_mesa_free((void *) stvp->state.tokens);
|
||||
stvp->state.tokens = NULL;
|
||||
}
|
||||
}
|
||||
@@ -167,7 +167,7 @@ st_delete_program(GLcontext *ctx, struct gl_program *prog)
|
||||
}
|
||||
|
||||
if (stfp->state.tokens) {
|
||||
FREE((void *) stfp->state.tokens);
|
||||
_mesa_free((void *) stfp->state.tokens);
|
||||
stfp->state.tokens = NULL;
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ static void st_program_string_notify( GLcontext *ctx,
|
||||
}
|
||||
|
||||
if (stfp->state.tokens) {
|
||||
FREE((void *) stfp->state.tokens);
|
||||
_mesa_free((void *) stfp->state.tokens);
|
||||
stfp->state.tokens = NULL;
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ static void st_program_string_notify( GLcontext *ctx,
|
||||
}
|
||||
|
||||
if (stvp->state.tokens) {
|
||||
FREE((void *) stvp->state.tokens);
|
||||
_mesa_free((void *) stvp->state.tokens);
|
||||
stvp->state.tokens = NULL;
|
||||
}
|
||||
|
||||
|
@@ -87,7 +87,7 @@ st_DeleteQuery(GLcontext *ctx, struct gl_query_object *q)
|
||||
stq->pq = NULL;
|
||||
}
|
||||
|
||||
FREE(stq);
|
||||
_mesa_free(stq);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -102,7 +102,7 @@ rastpos_line( struct draw_stage *stage, struct prim_header *prim )
|
||||
static void
|
||||
rastpos_destroy(struct draw_stage *stage)
|
||||
{
|
||||
free(stage);
|
||||
_mesa_free(stage);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -217,7 +217,7 @@ static void st_destroy_context_priv( struct st_context *st )
|
||||
st->default_texture = NULL;
|
||||
}
|
||||
|
||||
free( st );
|
||||
_mesa_free( st );
|
||||
}
|
||||
|
||||
|
||||
@@ -245,7 +245,7 @@ void st_destroy_context( struct st_context *st )
|
||||
|
||||
pipe->destroy( pipe );
|
||||
|
||||
free(ctx);
|
||||
_mesa_free(ctx);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -223,7 +223,7 @@ setup_edgeflags(GLcontext *ctx, GLenum primMode, GLint start, GLint count,
|
||||
if (!stobj)
|
||||
return NULL;
|
||||
|
||||
vec = (unsigned *) calloc(sizeof(unsigned), (count + 31) / 32);
|
||||
vec = (unsigned *) _mesa_calloc(sizeof(unsigned) * ((count + 31) / 32));
|
||||
if (!vec)
|
||||
return NULL;
|
||||
|
||||
|
@@ -61,9 +61,9 @@
|
||||
static INLINE void *
|
||||
mem_dup(const void *src, uint size)
|
||||
{
|
||||
void *dup = MALLOC(size);
|
||||
void *dup = _mesa_malloc(size);
|
||||
if (dup)
|
||||
memcpy(dup, src, size);
|
||||
_mesa_memcpy(dup, src, size);
|
||||
return dup;
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ st_translate_vertex_program(struct st_context *st,
|
||||
|
||||
/* free old shader state, if any */
|
||||
if (stvp->state.tokens) {
|
||||
FREE((void *) stvp->state.tokens);
|
||||
_mesa_free((void *) stvp->state.tokens);
|
||||
stvp->state.tokens = NULL;
|
||||
}
|
||||
if (stvp->driver_shader) {
|
||||
|
Reference in New Issue
Block a user