| 3011 | } |
| 3012 | |
| 3013 | FORCE_INLINE |
| 3014 | const char* to_hex_int32(int64_t context, int32_t data, int32_t* out_len) { |
| 3015 | const int32_t max_size = 2 * sizeof(int32_t); |
| 3016 | // Allocate one extra byte for the null terminator written by snprintf. |
| 3017 | auto ret = reinterpret_cast<char*>(gdv_fn_context_arena_malloc(context, max_size + 1)); |
| 3018 | |
| 3019 | if (ret == nullptr) { |
| 3020 | gdv_fn_context_set_error_msg(context, "Could not allocate memory for output string"); |
| 3021 | *out_len = 0; |
| 3022 | return ""; |
| 3023 | } |
| 3024 | snprintf(ret, max_size + 1, "%" PRIX32, data); |
| 3025 | |
| 3026 | *out_len = static_cast<int32_t>(strlen(ret)); |
| 3027 | return ret; |
| 3028 | } |
| 3029 | |
| 3030 | FORCE_INLINE |
| 3031 | const char* from_hex_utf8(int64_t context, const char* text, int32_t text_len, |