Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-pico
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-pico
Commits
486caf42
Unverified
Commit
486caf42
authored
Aug 29, 2022
by
Earle F. Philhower, III
Committed by
GitHub
Aug 29, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove microscopic malloc() from WebServer (#809)
Don't try and heap allocate temporaty <16b chunks.
parent
92f2ca91
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
17 deletions
+7
-17
libraries/WebServer/src/HTTPServer.cpp
libraries/WebServer/src/HTTPServer.cpp
+7
-17
No files found.
libraries/WebServer/src/HTTPServer.cpp
View file @
486caf42
...
...
@@ -87,10 +87,7 @@ static String md5str(String &in) {
char
out
[
33
]
=
{
0
};
MD5Builder
_ctx
;
uint8_t
i
;
uint8_t
*
_buf
=
(
uint8_t
*
)
malloc
(
16
);
if
(
_buf
==
NULL
)
{
return
String
(
out
);
}
uint8_t
_buf
[
16
];
memset
(
_buf
,
0x00
,
16
);
_ctx
.
begin
();
_ctx
.
add
((
const
uint8_t
*
)
in
.
c_str
(),
in
.
length
());
...
...
@@ -100,7 +97,6 @@ static String md5str(String &in) {
sprintf
(
out
+
(
i
*
2
),
"%02x"
,
_buf
[
i
]);
}
out
[
32
]
=
0
;
free
(
_buf
);
return
String
(
out
);
}
...
...
@@ -443,12 +439,9 @@ void HTTPServer::sendContent(const String& content) {
void
HTTPServer
::
sendContent
(
const
char
*
content
,
size_t
contentLength
)
{
const
char
*
footer
=
"
\r\n
"
;
if
(
_chunked
)
{
char
*
chunkSize
=
(
char
*
)
malloc
(
11
);
if
(
chunkSize
)
{
sprintf
(
chunkSize
,
"%x%s"
,
contentLength
,
footer
);
_currentClientWrite
(
chunkSize
,
strlen
(
chunkSize
));
free
(
chunkSize
);
}
char
chunkSize
[
11
];
sprintf
(
chunkSize
,
"%x%s"
,
contentLength
,
footer
);
_currentClientWrite
(
chunkSize
,
strlen
(
chunkSize
));
}
_currentClientWrite
(
content
,
contentLength
);
if
(
_chunked
)
{
...
...
@@ -466,12 +459,9 @@ void HTTPServer::sendContent_P(PGM_P content) {
void
HTTPServer
::
sendContent_P
(
PGM_P
content
,
size_t
size
)
{
const
char
*
footer
=
"
\r\n
"
;
if
(
_chunked
)
{
char
*
chunkSize
=
(
char
*
)
malloc
(
11
);
if
(
chunkSize
)
{
sprintf
(
chunkSize
,
"%x%s"
,
size
,
footer
);
_currentClientWrite
(
chunkSize
,
strlen
(
chunkSize
));
free
(
chunkSize
);
}
char
chunkSize
[
11
];
sprintf
(
chunkSize
,
"%x%s"
,
size
,
footer
);
_currentClientWrite
(
chunkSize
,
strlen
(
chunkSize
));
}
_currentClientWrite_P
(
content
,
size
);
if
(
_chunked
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment