diff --git a/core/dcb.c b/core/dcb.c index b73ed6845..1ad46c7df 100644 --- a/core/dcb.c +++ b/core/dcb.c @@ -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); } diff --git a/core/gwbitmask.c b/core/gwbitmask.c index 5d94bceb5..befdbb502 100644 --- a/core/gwbitmask.c +++ b/core/gwbitmask.c @@ -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 diff --git a/include/gwbitmask.h b/include/gwbitmask.h index e98383831..6b3b6b622 100644 --- a/include/gwbitmask.h +++ b/include/gwbitmask.h @@ -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);