8000
We read every piece of feedback, and take your input very seriously.
2 parents 8899f55 + 77ab33f commit 8a26750Copy full SHA for 8a26750
cores/esp8266/MD5Builder.cpp
@@ -24,43 +24,42 @@ void MD5Builder::addHexString(const char * data){
24
}
25
26
bool MD5Builder::addStream(Stream & stream, const size_t total_len) {
27
- const int buf_size = 512;
28
- int bytesleft = total_len;
29
- uint8_t * buf = (uint8_t*) malloc(buf_size);
30
- if(buf) {
31
- while((stream.available() > -1) && (bytesleft > 0)) {
+ const int buf_size = 512;
+ int bytesleft = total_len;
+ uint8_t * buf = (uint8_t*) malloc(buf_size);
+ if(buf) {
+ while((stream.available() > -1) && (bytesleft > 0)) {
32
+ // get available data size< 8000 /div>
33
+ int sizeAvailable = stream.available();
34
+ if(sizeAvailable) {
35
+ int readBytes = sizeAvailable;
36
- // get available data size
- int sizeAvailable = stream.available();
- if(sizeAvailable) {
- int readBytes = sizeAvailable;
37
-
38
- // read only the asked bytes
39
- if(readBytes > bytesleft) {
40
- readBytes = bytesleft ;
41
- }
+ // read only the asked bytes
+ if(readBytes > bytesleft) {
+ readBytes = bytesleft ;
+ }
42
43
- // not read more the buffer can handle
44
- if(readBytes > buf_size) {
45
- readBytes = buf_size;
46
+ // not read more the buffer can handle
+ if(readBytes > buf_size) {
+ readBytes = buf_size;
47
48
- // read data
49
- int bytesread = stream.readBytes(buf, readBytes);
50
- bytesleft -= bytesread;
51
- if(bytesread > 0) {
52
- MD5Update(&_ctx, buf, bytesread);
53
54
55
- // time for network streams
56
- delay(0);
+ // read data
+ int bytesread = stream.readBytes(buf, readBytes);
+ bytesleft -= bytesread;
+ if(bytesread > 0) {
+ MD5Update(&_ctx, buf, bytesread);
57
58
- // not free null ptr
59
- free(buf);
60
- return (bytesleft == 0);
61
- } else {
62
- return false;
+ // time for network streams
+ delay(0);
63
+ // guaranteed not null
+ free(buf);
+ return (bytesleft == 0);
+ } else {
+ return false;
64
65
66
void MD5Builder::calculate(void){
@@ -77,7 +76,7 @@ void MD5Builder::getChars(char * output){
77
76
78
79
String MD5Builder::toString(void){
80
- char out[32];
+ char out[33];
81
getChars(out);
82
return String(out);
83