*/
struct gl_renderbuffer
{
+#define RB_MAGIC 0xaabbccdd
+ int Magic; /** XXX TEMPORARY DEBUG INFO */
_glthread_Mutex Mutex; /**< for thread safety */
GLuint ClassID; /**< Useful for drivers */
GLuint Name;
{
_glthread_INIT_MUTEX(rb->Mutex);
+ rb->Magic = RB_MAGIC;
rb->ClassID = 0;
rb->Name = name;
rb->RefCount = 0;
GLboolean deleteFlag = GL_FALSE;
struct gl_renderbuffer *oldRb = *ptr;
+ assert(oldRb->Magic == RB_MAGIC);
_glthread_LOCK_MUTEX(oldRb->Mutex);
+ assert(oldRb->Magic == RB_MAGIC);
ASSERT(oldRb->RefCount > 0);
oldRb->RefCount--;
/*printf("RB DECR %p (%d) to %d\n", (void*) oldRb, oldRb->Name, oldRb->RefCount);*/
deleteFlag = (oldRb->RefCount == 0);
_glthread_UNLOCK_MUTEX(oldRb->Mutex);
- if (deleteFlag)
+ if (deleteFlag) {
+ oldRb->Magic = 0; /* now invalid memory! */
oldRb->Delete(oldRb);
+ }
*ptr = NULL;
}
assert(!*ptr);
if (rb) {
+ assert(rb->Magic == RB_MAGIC);
/* reference new renderbuffer */
_glthread_LOCK_MUTEX(rb->Mutex);
rb->RefCount++;