diff options
author | Devtools Arcadia <[email protected]> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <[email protected]> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /contrib/restricted/aws/aws-c-common/source/math.c |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'contrib/restricted/aws/aws-c-common/source/math.c')
-rw-r--r-- | contrib/restricted/aws/aws-c-common/source/math.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/contrib/restricted/aws/aws-c-common/source/math.c b/contrib/restricted/aws/aws-c-common/source/math.c new file mode 100644 index 00000000000..40d833c1a94 --- /dev/null +++ b/contrib/restricted/aws/aws-c-common/source/math.c @@ -0,0 +1,24 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#include <aws/common/math.h> +#include <stdarg.h> + +AWS_COMMON_API int aws_add_size_checked_varargs(size_t num, size_t *r, ...) { + va_list argp; + va_start(argp, r); + + size_t accum = 0; + for (size_t i = 0; i < num; ++i) { + size_t next = va_arg(argp, size_t); + if (aws_add_size_checked(accum, next, &accum) == AWS_OP_ERR) { + va_end(argp); + return AWS_OP_ERR; + } + } + *r = accum; + va_end(argp); + return AWS_OP_SUCCESS; +} |