Module: Mesa
Branch: gallium-0.2
Commit: 28a2edb7389107cd46eb382a44d339dd7972310a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=28a2edb7389107cd46eb382a44d339dd7972310a
Author: José Fonseca <[EMAIL PROTECTED]>
Date: Tue Oct 28 16:11:09 2008 +0900
pipebuffer: Ensure refcounts of live buffer objects are never zero.
---
src/gallium/auxiliary/pipebuffer/pb_buffer.h | 15 ++++++++++++---
.../auxiliary/pipebuffer/pb_bufmgr_fenced.c | 3 +--
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer.h
b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
index 8505d33..19db8a6 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
@@ -177,12 +177,16 @@ pb_get_base_buffer( struct pb_buffer *buf,
}
+/**
+ * Don't call this directly. Use pb_reference instead.
+ */
static INLINE void
pb_destroy(struct pb_buffer *buf)
{
assert(buf);
if(!buf)
return;
+ assert(buf->base.refcount == 0);
buf->vtbl->destroy(buf);
}
@@ -193,11 +197,16 @@ static INLINE void
pb_reference(struct pb_buffer **dst,
struct pb_buffer *src)
{
- if (src)
+ if (src) {
+ assert(src->base.refcount);
src->base.refcount++;
+ }
- if (*dst && --(*dst)->base.refcount == 0)
- pb_destroy( *dst );
+ if (*dst) {
+ assert((*dst)->base.refcount);
+ if(--(*dst)->base.refcount == 0)
+ pb_destroy( *dst );
+ }
*dst = src;
}
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c
b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c
index 633ee70..e2594ea 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c
@@ -86,8 +86,7 @@ fenced_bufmgr_create_buffer(struct pb_manager *mgr,
fenced_buf = fenced_buffer_create(fenced_mgr->fenced_list, buf);
if(!fenced_buf) {
- assert(buf->base.refcount == 1);
- pb_destroy(buf);
+ pb_reference(&buf, NULL);
}
return fenced_buf;
_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit