Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 259ff80

Browse filesBrowse files
marcelkottmannme-no-dev
authored andcommitted
use libbase64 macro to calculate base64 length (espressif#2007)
1 parent 3902aa4 commit 259ff80
Copy full SHA for 259ff80

File tree

Expand file treeCollapse file tree

2 files changed

+1
-11
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+1
-11
lines changed

‎cores/esp32/base64.cpp

Copy file name to clipboardExpand all lines: cores/esp32/base64.cpp
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ extern "C" {
3737
*/
3838
String base64::encode(uint8_t * data, size_t length)
3939
{
40-
// base64 needs more size then the source data
41-
size_t size = ((length * 1.6f) + 1);
40+
size_t size = base64_encode_expected_len(length) + 1;
4241
char * buffer = (char *) malloc(size);
4342
if(buffer) {
4443
base64_encodestate _state;

‎cores/esp32/libb64/cencode.c

Copy file name to clipboardExpand all lines: cores/esp32/libb64/cencode.c
-9Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,10 @@ For details, see http://sourceforge.net/projects/libb64
77

88
#include "cencode.h"
99

10-
const int CHARS_PER_LINE = 72;
11-
1210
void base64_init_encodestate(base64_encodestate* state_in)
1311
{
1412
state_in->step = step_A;
1513
state_in->result = 0;
16-
state_in->stepcount = 0;
1714
}
1815

1916
char base64_encode_value(char value_in)
@@ -68,12 +65,6 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out,
6865
*codechar++ = base64_encode_value(result);
6966
result = (fragment & 0x03f) >> 0;
7067
*codechar++ = base64_encode_value(result);
71-
72-
++(state_in->stepcount);
73-
if (state_in->stepcount == CHARS_PER_LINE/4) {
74-
*codechar++ = '\n';
75-
state_in->stepcount = 0;
76-
}
7768
}
7869
}
7970
/* control should not reach here */

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.