Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make buffer for converting decimal128 to string thread local #1477

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/realm_dart_decimal128.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ RLM_API realm_decimal128_t realm_dart_decimal128_from_string(const char* string)
return to_decimal128(result);
}

// This buffer is reused between calls, hence it is thread local
thread_local char _decimal128_to_string_buffer[34];
RLM_API realm_string_t realm_dart_decimal128_to_string(realm_decimal128_t x) {
auto x_bid = to_BID_UINT128(x);
// This buffer is reused between calls, hence the static keyword
static char buffer[34]; // 34 bytes is the maximum length of a string representation of a decimal128
unsigned int flags = 0;
bid128_to_string(buffer, &x_bid, &flags);
return realm_string_t{ buffer, strlen(buffer) };
bid128_to_string(_decimal128_to_string_buffer, &x_bid, &flags);
return realm_string_t{ _decimal128_to_string_buffer, strlen(_decimal128_to_string_buffer) };
}

RLM_API realm_decimal128_t realm_dart_decimal128_nan() {
Expand Down
Loading