Files
codeql/cpp/ql/src/Critical/LargeParameter.cpp
Patrik Schönfeldt ac249cdbbe Fix reccomendation for LargeParameter (C++)
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.
2019-02-03 15:44:13 +01:00

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
...
}