core: change policy incrementation to prefix op

Using prefix incrementation makes sure a policy with id == 0 is
invalid.

Fixes #1049.
This commit is contained in:
Josef Söntgen 2014-01-28 16:19:10 +01:00 committed by Norman Feske
parent e68eadf57b
commit e79044d16a

View File

@ -41,7 +41,11 @@ Policy_id Session_component::alloc_policy(size_t size)
if (size > _argument_buffer.size)
throw Policy_too_large();
Policy_id const id(_policy_cnt++);
/*
* Using prefix incrementation makes sure a policy with id == 0 is
* invalid.
*/
Policy_id const id(++_policy_cnt);
if (!_md_alloc.withdraw(size))
throw Out_of_metadata();