Fixed memory leak in the DCB bitmask

This commit is contained in:
Mark Riddoch
2013-07-09 01:37:20 +02:00
parent 23b2a95d5a
commit c4d8501d75
3 changed files with 17 additions and 0 deletions

View File

@ -183,6 +183,7 @@ dcb_final_free(DCB *dcb)
free(dcb->data);
if (dcb->remote)
free(dcb->remote);
bitmask_free(&dcb->memdata.bitmask);
free(dcb);
}

View File

@ -53,6 +53,21 @@ bitmask_init(GWBITMASK *bitmask)
spinlock_init(&bitmask->lock);
}
/**
* Free a bitmask that is no longer required
*
* @param bitmask
*/
void
bitmask_free(GWBITMASK *bitmask)
{
if (bitmask->length)
{
free(bitmask->bits);
bitmask->length = 0;
}
}
/**
* Set the bit at the specified bit position in the bitmask.
* The bitmask will automatically be extended if the bit is

View File

@ -44,6 +44,7 @@ typedef struct {
} GWBITMASK;
extern void bitmask_init(GWBITMASK *);
extern void bitmask_free(GWBITMASK *);
extern void bitmask_set(GWBITMASK *, int);
extern void bitmask_clear(GWBITMASK *, int);
extern int bitmask_isset(GWBITMASK *, int);