mirror of
https://github.com/github/codeql.git
synced 2025-12-25 05:06:34 +01:00
The previous reccomentation changed the behaviour of the code. A user following the advice might have broken her/his code: With call-by-value, the original parameter is not changed. With a call-by-reference, however, it may be changed. To be sure, nothing breaks by blindly following the advice, suggest to pass a const reference.
14 lines
317 B
C++
14 lines
317 B
C++
typedef struct Names {
|
|
char first[100];
|
|
char last[100];
|
|
} Names;
|
|
|
|
int doFoo(Names n) { //wrong: n is passed by value (meaning the entire structure
|
|
//is copied onto the stack, instead of just a pointer)
|
|
...
|
|
}
|
|
|
|
int doBar(const Names &n) { //better, only a reference is passed
|
|
...
|
|
}
|