Skip to content

Commit 35b0b31

Browse files
author
Micah Scott
committed
Reconsider function name (_bson_round_up_alloc_size)
The new name doesn't misleadingly imply that the result is always a power of two.
1 parent 3e4ec4b commit 35b0b31

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/libbson/src/bson/bson.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static const uint8_t gZero;
6464
/*
6565
*--------------------------------------------------------------------------
6666
*
67-
* _bson_next_power_of_two_for_alloc --
67+
* _bson_round_up_alloc_size --
6868
*
6969
* Given a potential allocation length in bytes, round up to the
7070
* next power of two without exceeding BSON_MAX_SIZE.
@@ -81,7 +81,7 @@ static const uint8_t gZero;
8181
*/
8282

8383
static BSON_INLINE size_t
84-
_bson_next_power_of_two_for_alloc (size_t size)
84+
_bson_round_up_alloc_size (size_t size)
8585
{
8686
if (size <= BSON_MAX_SIZE) {
8787
size_t power_of_two = bson_next_power_of_two (size);
@@ -121,7 +121,7 @@ _bson_impl_inline_grow (bson_impl_inline_t *impl, /* IN */
121121
return true;
122122
}
123123

124-
req = _bson_next_power_of_two_for_alloc (impl->len + size);
124+
req = _bson_round_up_alloc_size (impl->len + size);
125125

126126
if (req <= BSON_MAX_SIZE) {
127127
data = bson_malloc (req);
@@ -188,7 +188,7 @@ _bson_impl_alloc_grow (bson_impl_alloc_t *impl, /* IN */
188188
return true;
189189
}
190190

191-
req = _bson_next_power_of_two_for_alloc (req);
191+
req = _bson_round_up_alloc_size (req);
192192

193193
if ((req <= BSON_MAX_SIZE) && impl->realloc) {
194194
*impl->buf = impl->realloc (*impl->buf, req, impl->realloc_func_ctx);
@@ -2136,7 +2136,7 @@ bson_copy_to (const bson_t *src, bson_t *dst)
21362136
}
21372137

21382138
data = _bson_data (src);
2139-
len = _bson_next_power_of_two_for_alloc ((size_t) src->len);
2139+
len = _bson_round_up_alloc_size ((size_t) src->len);
21402140

21412141
adst = (bson_impl_alloc_t *) dst;
21422142
adst->flags = BSON_FLAG_STATIC;

0 commit comments

Comments
 (0)