Comparing the return value of atomic_add instead of buffer's reference count variable.
This commit is contained in:
VilhoRaatikka
2014-02-12 18:55:44 +02:00
parent cb20f8ab8d
commit b673108276

View File

@ -94,12 +94,11 @@ SHARED_BUF *sbuf;
void void
gwbuf_free(GWBUF *buf) gwbuf_free(GWBUF *buf)
{ {
atomic_add(&buf->sbuf->refcount, -1); CHK_GWBUF(buf);
CHK_GWBUF(buf); if (atomic_add(&buf->sbuf->refcount, -1) == 1)
if (buf->sbuf->refcount == 0)
{ {
free(buf->sbuf->data); free(buf->sbuf->data);
free(buf->sbuf); free(buf->sbuf);
} }
free(buf); free(buf);
} }