@@ -87,10 +87,7 @@ static String md5str(String &in) {
87
87
char out[33 ] = {0 };
88
88
MD5Builder _ctx;
89
89
uint8_t i;
90
- uint8_t * _buf = (uint8_t *)malloc (16 );
91
- if (_buf == NULL ) {
92
- return String (out);
93
- }
90
+ uint8_t _buf[16 ];
94
91
memset (_buf, 0x00 , 16 );
95
92
_ctx.begin ();
96
93
_ctx.add ((const uint8_t *)in.c_str (), in.length ());
@@ -100,7 +97,6 @@ static String md5str(String &in) {
100
97
sprintf (out + (i * 2 ), " %02x" , _buf[i]);
101
98
}
102
99
out[32 ] = 0 ;
103
- free (_buf);
104
100
return String (out);
105
101
}
106
102
@@ -443,12 +439,9 @@ void HTTPServer::sendContent(const String& content) {
443
439
void HTTPServer::sendContent (const char * content, size_t contentLength) {
444
440
const char * footer = " \r\n " ;
445
441
if (_chunked) {
446
- char * chunkSize = (char *)malloc (11 );
447
- if (chunkSize) {
448
- sprintf (chunkSize, " %x%s" , contentLength, footer);
449
- _currentClientWrite (chunkSize, strlen (chunkSize));
450
- free (chunkSize);
451
- }
442
+ char chunkSize[11 ];
443
+ sprintf (chunkSize, " %x%s" , contentLength, footer);
444
+ _currentClientWrite (chunkSize, strlen (chunkSize));
452
445
}
453
446
_currentClientWrite (content, contentLength);
454
447
if (_chunked) {
@@ -466,12 +459,9 @@ void HTTPServer::sendContent_P(PGM_P content) {
466
459
void HTTPServer::sendContent_P (PGM_P content, size_t size) {
467
460
const char * footer = " \r\n " ;
468
461
if (_chunked) {
469
- char * chunkSize = (char *)malloc (11 );
470
- if (chunkSize) {
471
- sprintf (chunkSize, " %x%s" , size, footer);
472
- _currentClientWrite (chunkSize, strlen (chunkSize));
473
- free (chunkSize);
474
- }
462
+ char chunkSize[11 ];
463
+ sprintf (chunkSize, " %x%s" , size, footer);
464
+ _currentClientWrite (chunkSize, strlen (chunkSize));
475
465
}
476
466
_currentClientWrite_P (content, size);
477
467
if (_chunked) {
0 commit comments