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

src: use const parameters in base64_decode_slow() #12144

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
src: use const parameters in base64_decode_slow()
Make parameters as const since it's both better at its own and
consistent with base64_decode_fast() and base64_decode().
  • Loading branch information
aqrln committed Mar 31, 2017
commit 008bbbced6a49ca460007eccba45e7bf72ee6c4c
4 changes: 2 additions & 2 deletions src/base64.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ extern const int8_t unbase64_table[256];


template <typename TypeName>
size_t base64_decode_slow(char* dst, size_t dstlen,
const TypeName* src, size_t srclen) {
size_t base64_decode_slow(char* const dst, const size_t dstlen,
const TypeName* const src, const size_t srclen) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the second const for src necessary?

Copy link
Contributor Author

@aqrln aqrln Mar 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not strictly necessary, but why not add it if we don't mutate the pointer? And that would be consistent with base64_decode_slow() (line 90) and base64_decode() (line 122).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@richardlau The first const declares the pointed-to memory immutable, the second one declares the pointer itself immutable (i.e., not reassignable.)

uint8_t hi;
uint8_t lo;
size_t i = 0;
Expand Down