2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-22 18:19:42 +00:00

added isc_quota_attach(), isc_quota_detach()

This commit is contained in:
Andreas Gustafsson 2000-01-15 00:32:42 +00:00
parent 16804ba3b7
commit 8c36d7eeb9
2 changed files with 33 additions and 0 deletions

View File

@ -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 */

View File

@ -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;
}