Commit 8c36d7ee authored by Andreas Gustafsson's avatar Andreas Gustafsson
Browse files

added isc_quota_attach(), isc_quota_detach()

parent 16804ba3
......@@ -87,6 +87,21 @@ isc_quota_release(isc_quota_t *quota);
* Release one unit of quota.
*/
isc_result_t
isc_quota_attach(isc_quota_t *quota, isc_quota_t **p);
/*
* Like isc_quota_reserve, and also attaches '*p' to the
* quota if successful.
*/
void
isc_quota_detach(isc_quota_t **p);
/*
* Like isc_quota_release, and also detaches '*p' from the
* quota.
*/
ISC_LANG_ENDDECLS
#endif /* ISC_QUOTA_H */
......@@ -55,4 +55,22 @@ isc_quota_release(isc_quota_t *quota) {
UNLOCK(&quota->lock);
}
isc_result_t
isc_quota_attach(isc_quota_t *quota, isc_quota_t **p)
{
isc_result_t result;
INSIST(p != NULL && *p == NULL);
result = isc_quota_reserve(quota);
if (result != ISC_R_SUCCESS)
return (result);
*p = quota;
return (ISC_R_SUCCESS);
}
void
isc_quota_detach(isc_quota_t **p)
{
INSIST(p != NULL && *p != NULL);
isc_quota_release(*p);
*p = NULL;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment