From 661b9ce39bacbade9eb841230a7456f6dcf9aac0 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sun, 4 Dec 2022 22:55:27 +0100 Subject: [PATCH] Return error EFBIG, if the set or map cannot grow any further because of the SIZE_MAX limit. --- README.md | 10 ++++++++-- libhashset/src/generic_hash_map.h | 2 +- libhashset/src/generic_hash_set.h | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 55f297a..215c9d0 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/libhashset/src/generic_hash_map.h b/libhashset/src/generic_hash_map.h index 0f621a9..1de8864 100644 --- a/libhashset/src/generic_hash_map.h +++ b/libhashset/src/generic_hash_map.h @@ -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!*/ } } diff --git a/libhashset/src/generic_hash_set.h b/libhashset/src/generic_hash_set.h index bc771b9..4b6ee78 100644 --- a/libhashset/src/generic_hash_set.h +++ b/libhashset/src/generic_hash_set.h @@ -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!*/ } }