Skip to content

use strdup instead of manual malloc+memcpy #42

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

Open
ret2libc opened this issue Jan 21, 2019 · 2 comments
Open

use strdup instead of manual malloc+memcpy #42

ret2libc opened this issue Jan 21, 2019 · 2 comments
Assignees

Comments

@ret2libc
Copy link

In multiple places strings are copied from one place to another, but instead of using strdup or the str* functions, the project seems to prefer malloc+memcpy, which IMHO results in less readable more error-prone code.

Examples of this:

memcpy(rtd->key, key, sizeof(char)*keylen);

memcpy(ret, xmlstr, sizeof(char)*(strlen(xmlstr)+1));

memcpy(attr->name, name, sizeof(char)*(strlen(name)+1));

memcpy(attr->val, val, sizeof(char)*(strlen(val)+1));

.. and many others.

@dcantrell dcantrell self-assigned this May 10, 2023
@dcantrell
Copy link

I agree. The malloc+memcpy style is harder to read. Patch coming soon.

@j-mracek
Copy link
Contributor

I agree that it looks not nice but if there is not an issue, I would prefer to keep it like it is. Please look at the patch frequency in the project and you will discover that the project has not much contribution. In future it will be even not used by DNF5.

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

No branches or pull requests

3 participants