mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-04 01:50:35 +02:00
radeong: Test the BO ptr for NULL instead of using a bool.
Slight memory savings, but more importantly also avoids a potential NULL dereference.
This commit is contained in:
parent
c2d17dce27
commit
20dedcca3c
1 changed files with 4 additions and 8 deletions
|
|
@ -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);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue