Debian Codegraph @

crt/aws-c-common/include/aws/common/private/byte_buf.h

raw symbols SCIP
1 #ifndef AWS_COMMON_PRIVATE_BYTE_BUF_H
2 #define AWS_COMMON_PRIVATE_BYTE_BUF_H
3 /**
4 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 * SPDX-License-Identifier: Apache-2.0.
6 */
7
8 #include <aws/common/byte_buf.h>
9
10 /**
11 * If index >= bound, bound > (SIZE_MAX / 2), or index > (SIZE_MAX / 2), returns
12 * 0. Otherwise, returns UINTPTR_MAX. This function is designed to return the correct
13 * value even under CPU speculation conditions, and is intended to be used for
14 * SPECTRE mitigation purposes.
15 */
16 AWS_COMMON_API size_t aws_nospec_mask(size_t index, size_t bound);
17
18 /**
19 * Expand the buffer appropriately to meet the requested capacity.
20 *
21 * If the the buffer's capacity is currently larger than the request capacity, the
22 * function does nothing (no shrink is performed).
23 */
24 AWS_COMMON_API
25 int aws_byte_buf_reserve_smart(struct aws_byte_buf *buffer, size_t requested_capacity);
26
27 /**
28 * Convenience function that attempts to increase the capacity of a buffer relative to the current
29 * length appropriately.
30 *
31 * If the the buffer's capacity is currently larger than the request capacity, the
32 * function does nothing (no shrink is performed).
33 */
34 AWS_COMMON_API
35 int aws_byte_buf_reserve_smart_relative(struct aws_byte_buf *buffer, size_t additional_length);
36
37 #endif /* AWS_COMMON_PRIVATE_BYTE_BUF_H */