Skip to content

More allocated bytes than necessary #10024

@xtonik

Description

@xtonik

There is allocated more memory than used for encoding strings in base64.

The implementation always produces base64 strings aligned to four bytes plus one zero terminating character, but number of bytes allocated is higher - see attached encoded_lengths.csv.

It is possible of course, that no memory is saved due to alignment to several bytes blocks for CPU optimization - for alignment to 8 bytes blocks is current implementation correct, but as it is platform dependent, this could not be true in every cases.

Proposed solution:
Replace expression insize * 4 / 3 + 4 with (insize + 2) / 3 * 4 + 1 at line referenced above.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions