Skip to content

Mark all string parameters as comptime where the C API is expecting string literals. - #7

Open
jhark wants to merge 2 commits into
zig-gamedev:mainfrom
jhark:string-literals
Open

Mark all string parameters as comptime where the C API is expecting string literals.#7
jhark wants to merge 2 commits into
zig-gamedev:mainfrom
jhark:string-literals

Conversation

@jhark

@jhark jhark commented Mar 25, 2025

Copy link
Copy Markdown

Pros:

  • Prevents mistaken usage of dynamically allocated strings.
  • Lets us use static constant memory for the source location data.
  • Avoids generating unnecessary writes to source location data whenever starting a zone.
  • Matches other Zig Tracy bindings such as the one inside the Zig compiler.

Cons:

  • Breaking API change.
  • Technically you are allowed to pass non-string literals to these functions, and you might want to if you are dynamically loading code/data containing your strings, or promise to keep your strings allocated until program exit. We could export the raw C API to cover more niche use-cases such as these though.

jhark added 2 commits March 25, 2025 13:04
…tring literals.

Pros:

* Prevents mistaken usage of dynamically allocated strings.
* Lets us use static constant memory for the source location data.
* Avoids generating unnecessary writes to source location data whenever starting a zone.
* Matches other Zig Tracy bindings such as the one inside the Zig compiler.

Cons:

* Breaking API change.
* Technically you are allowed to pass non-string literals to these functions, and you might want to if you are dynamically loading code/data containing your strings, or promise to keep your strings allocated until program exit. We could export the raw C API to cover more niche use-cases such as these though.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants