diff options
author | José Fonseca <[email protected]> | 2008-10-28 16:11:09 +0900 |
---|---|---|
committer | José Fonseca <[email protected]> | 2008-11-03 22:35:18 +0900 |
commit | 28a2edb7389107cd46eb382a44d339dd7972310a (patch) | |
tree | 7cb8b1d6ed1b5d9b6ece8958ee63cceea20fe3cd /src/gallium/auxiliary/pipebuffer/pb_buffer.h | |
parent | 467c4760b337a541c7af27f1ed3bd5c4ecba316f (diff) |
pipebuffer: Ensure refcounts of live buffer objects are never zero.
Diffstat (limited to 'src/gallium/auxiliary/pipebuffer/pb_buffer.h')
-rw-r--r-- | src/gallium/auxiliary/pipebuffer/pb_buffer.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer.h b/src/gallium/auxiliary/pipebuffer/pb_buffer.h index 8505d333bda..19db8a6a913 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; } |