| 2993 | } |
| 2994 | |
| 2995 | FORCE_INLINE |
| 2996 | const char* to_hex_int64(int64_t context, int64_t data, int32_t* out_len) { |
| 2997 | const int64_t hex_long_max_size = 2 * sizeof(int64_t); |
| 2998 | // Allocate one extra byte for the null terminator written by snprintf. |
| 2999 | auto ret = reinterpret_cast<char*>( |
| 3000 | gdv_fn_context_arena_malloc(context, hex_long_max_size + 1)); |
| 3001 | |
| 3002 | if (ret == nullptr) { |
| 3003 | gdv_fn_context_set_error_msg(context, "Could not allocate memory for output string"); |
| 3004 | *out_len = 0; |
| 3005 | return ""; |
| 3006 | } |
| 3007 | snprintf(ret, hex_long_max_size + 1, "%" PRIX64, data); |
| 3008 | |
| 3009 | *out_len = static_cast<int32_t>(strlen(ret)); |
| 3010 | return ret; |
| 3011 | } |
| 3012 | |
| 3013 | FORCE_INLINE |
| 3014 | const char* to_hex_int32(int64_t context, int32_t data, int32_t* out_len) { |