From 20dedcca3ca5bfeaaa275bec8a14ca8c69615f6a Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 20 Mar 2010 16:14:20 -0700 Subject: radeong: Test the BO ptr for NULL instead of using a bool. Slight memory savings, but more importantly also avoids a potential NULL dereference. --- src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c index 73472aabc5..2f7456e12d 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c @@ -23,7 +23,6 @@ struct radeon_drm_buffer { boolean flinked; uint32_t flink; - boolean mapped; struct radeon_drm_buffer *next, *prev; }; @@ -56,10 +55,10 @@ radeon_drm_buffer_destroy(struct pb_buffer *_buf) { struct radeon_drm_buffer *buf = radeon_drm_buffer(_buf); - if (buf->mapped) { + if (buf->bo->ptr != NULL) { remove_from_list(buf); radeon_bo_unmap(buf->bo); - buf->mapped = false; + buf->bo->ptr = NULL; } radeon_bo_unref(buf->bo); @@ -73,7 +72,7 @@ radeon_drm_buffer_map(struct pb_buffer *_buf, struct radeon_drm_buffer *buf = radeon_drm_buffer(_buf); int write; - if (buf->mapped) + if (buf->bo->ptr != NULL) return buf->bo->ptr; if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) { @@ -95,7 +94,6 @@ radeon_drm_buffer_map(struct pb_buffer *_buf, if (radeon_bo_map(buf->bo, write)) { return NULL; } - buf->mapped = true; insert_at_tail(&buf->mgr->buffer_map_list, buf); return buf->bo->ptr; } @@ -365,12 +363,10 @@ void radeon_drm_bufmgr_flush_maps(struct pb_manager *_mgr) struct radeon_drm_buffer *rpb, *t_rpb; foreach_s(rpb, t_rpb, &mgr->buffer_map_list) { - rpb->mapped = 0; radeon_bo_unmap(rpb->bo); + rpb->bo->ptr = NULL; remove_from_list(rpb); } make_empty_list(&mgr->buffer_map_list); - - } -- cgit v1.2.3