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

common/DCGMStringHelpers: use memccpy for performance & error handling #142

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ecbadeaux
Copy link

@ecbadeaux ecbadeaux commented Dec 21, 2023

Hello my name is Everett Badeaux. I just wanted to make the pull request to improve the performance and functionality of your string copy command. Can we connect?

Here are a few of the performance benefits of the new implementation:

  • In your implementation strncpy would continue to copy null bytes until it wrote the amount specified destination size. This is not needed. With memccpy execution will immediately stop once the null terminator is encountered. This can be a great performance benefit if the dest is exponentially larger than the src.
  • You also had no way of knowing if the source buffer was larger than the destination buffer. Now false will be returned if the null terminating character is not encountered otherwise true indicating successful copy.
  • Keeps your old implementation that if the source is not null terminated we will add at len -1 position
  • Unit tests

Signed-off-by: Everett Badeaux <everettc1810@gmail.com>
@ecbadeaux
Copy link
Author

@nikkon-dev Hey is this still an active project?

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