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

da_move could lead to undesired side effects #74

Open
drocha87 opened this issue Feb 17, 2023 · 1 comment
Open

da_move could lead to undesired side effects #74

drocha87 opened this issue Feb 17, 2023 · 1 comment

Comments

@drocha87
Copy link

ded/src/common.h

Lines 37 to 43 in 57d23fa

#define da_move(dst, src) \
do { \
free((dst)->items); \
(dst)->items = (src).items; \
(dst)->count = (src).count; \
(dst)->capacity = (src).capacity; \
} while (0)

I think that we should "clear" src after moving it to dst (setting (src).items = NULL; and zeroing its count and capacity).

Since src still holds a pointer to items it could cause undesired side effects.

@BillKek
Copy link
Contributor

BillKek commented Feb 18, 2023

I think this is a C++ problem. And C is immune.

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

2 participants