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

Replace some memcpy calls with struct assignments #878

Conversation

wantehchang
Copy link
Collaborator

An advantage of struct assignments is that the compiler does type
checking. It will also avoid the potential mistake of passing an
incorrect third argument to memcpy().

To avoid conflict with a pending pull request, this pull request does
not change src/read.c.

An advantage of struct assignments is that the compiler does type
checking. It will also avoid the potential mistake of passing an
incorrect third argument to memcpy().

To avoid conflict with a pending pull request, this pull request does
not change src/read.c.
@jzern
Copy link
Collaborator

jzern commented Mar 15, 2022

lgtm. This is part of the motivation of preferring sizeof(var) over sizeof(type) in other constructions. In the end these should become memcpy's. Was there a bug?

@wantehchang
Copy link
Collaborator Author

@jzern James: There was a bug caused by a copy-and-paste error of the sizeof(var) argument to memcpy(): #483.

@wantehchang wantehchang merged commit 21961f4 into AOMediaCodec:master Mar 15, 2022
@wantehchang wantehchang deleted the replace-memcpy-with-struct-assignment branch March 15, 2022 15:46
wantehchang added a commit to wantehchang/libavif that referenced this pull request Mar 17, 2022
An advantage of struct assignments is that the compiler does type
checking. It will also avoid the potential mistake of passing an
incorrect third argument to memcpy().

This pull request finishes the job of
AOMediaCodec#878.
wantehchang added a commit to wantehchang/libavif that referenced this pull request Mar 17, 2022
An advantage of struct assignments is that the compiler does type
checking. It will also avoid the potential mistake of passing an
incorrect third argument to memcpy().

This pull request finishes the job of
AOMediaCodec#878.
wantehchang added a commit that referenced this pull request Mar 17, 2022
An advantage of struct assignments is that the compiler does type
checking. It will also avoid the potential mistake of passing an
incorrect third argument to memcpy().

This pull request finishes the job of
#878.
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.

3 participants