diff options
| author | gingerBill <bill@gingerbill.org> | 2024-04-08 16:08:35 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-04-08 16:08:35 +0100 |
| commit | 810cf22e5ddd772ee214eec306b1ba148623302c (patch) | |
| tree | 92421e8b8d605d7aba7799caa56a75b128f0bc2d /src/common.cpp | |
| parent | 16dc79fc5c98228471ed57eb0f8e853de739f6d9 (diff) | |
Obfuscate `#file` and `#procedure` when `-obfuscate-source-code-locations` is enabled
Diffstat (limited to 'src/common.cpp')
| -rw-r--r-- | src/common.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/common.cpp b/src/common.cpp index aad420325..6a53332d9 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -353,6 +353,19 @@ gb_global bool global_module_path_set = false; #include "thread_pool.cpp" +gb_internal String obfuscate_string(String const &s, char const *prefix) { + if (s.len == 0) { + return {}; + } + GB_ASSERT(prefix != nullptr); + u64 hash = gb_fnv64a(s.text, s.len); + gbString res = gb_string_make(temporary_allocator(), prefix); + res = gb_string_append_fmt(res, "x%llx", cast(long long unsigned)hash); + return make_string_c(res); +} + + + struct StringIntern { StringIntern *next; isize len; |