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

Null terminate public strings #9

Merged
merged 4 commits into from
Jan 20, 2020
Merged

Null terminate public strings #9

merged 4 commits into from
Jan 20, 2020

Conversation

mratsim
Copy link
Contributor

@mratsim mratsim commented Jan 19, 2020

This ensures that public strings are null-terminated so that they can be passed as-is to raw C routines.
It fixes #8

In terms of performance we have for request.data.toString(request.url.s, request.url.e):

  • allocation of a string of length L (+1 for null byte)
  • copyMem of a slice of length L

The original code cast[string](request.data[request.url.s..request.url.e]) had

  • allocation of a seq[byte] of length L
  • copyMem of a byte slice of length L
  • reinterpreting the memory

So we should be as efficient.

@zah zah merged commit 33d70b9 into master Jan 20, 2020
@delete-merged-branch delete-merged-branch bot deleted the null-terminate-public-strings branch January 20, 2020 17:41
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.

HttpReqRespHeader.data slices are not null-terminated
2 participants