Return error EFBIG, if the set or map cannot grow any further because of the SIZE_MAX limit.

This commit is contained in:
LoRd_MuldeR 2022-12-04 22:55:27 +01:00
parent 669bf3a28b
commit 661b9ce39b
3 changed files with 10 additions and 4 deletions

View File

@ -195,7 +195,10 @@ On success, this function returns *zero*. On error, the appropriate error code i
The given item was *not* inserted into the hash set (again), because it was already present.
* `ENOMEM`
The item could *not* be inserted, because the required amount of memory could *not* be allocated.
The set failed to grow, because the required amount of memory could *not* be allocated (out of memory).
* `EFBIG`
The set needs to grow, but doing so would exceed the maximum size supported by the underlying system.
* `EFAULT`
Something else went wrong. This usually indicates an internal error and is *not* supposed to happen.
@ -551,7 +554,10 @@ On success, this function returns *zero*. On error, the appropriate error code i
Nonetheless, if `update` was non-zero, the value associated with the existing key has been updated.
* `ENOMEM`
The key could *not* be inserted, because the required amount of memory could *not* be allocated.
The map failed to grow, because the required amount of memory could *not* be allocated (out of memory).
* `EFBIG`
The map needs to grow, but doing so would exceed the maximum size supported by the underlying system.
* `EFAULT`
Something else went wrong. This usually indicates an internal error and is *not* supposed to happen.

View File

@ -265,7 +265,7 @@ errno_t DECLARE(hash_map_insert)(hash_map_t *const instance, const value_t key,
}
else
{
return ENOMEM; /*can not grow any futher!*/
return EFBIG; /*can not grow any futher!*/
}
}

View File

@ -252,7 +252,7 @@ errno_t DECLARE(hash_set_insert)(hash_set_t *const instance, const value_t item)
}
else
{
return ENOMEM; /*can not grow any futher!*/
return EFBIG; /*can not grow any futher!*/
}
}