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

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jhark
Copy link

@jhark jhark commented Mar 25, 2025

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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant