NetworkPkg: Avoid memory allocation for each HTTP message exchange.
This patch updates the HTTP driver to use a shared buffer for URL parsing to avoid memory allocation for each HTTP request. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Fu Siyuan <siyuan.fu@intel.com> Reviewed-by: Ye Ting <ting.ye@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18449 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -224,6 +224,7 @@ EfiHttpRequest (
|
||||
BOOLEAN ReConfigure;
|
||||
CHAR8 *RequestStr;
|
||||
CHAR8 *Url;
|
||||
UINTN UrlLen;
|
||||
CHAR16 *HostNameStr;
|
||||
HTTP_TOKEN_WRAP *Wrap;
|
||||
HTTP_TCP_TOKEN_WRAP *TcpWrap;
|
||||
@@ -283,10 +284,15 @@ EfiHttpRequest (
|
||||
//
|
||||
// Parse the URI of the remote host.
|
||||
//
|
||||
Url = AllocatePool (StrLen (Request->Url) + 1);
|
||||
if (Url == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
UrlLen = StrLen (Request->Url) + 1;
|
||||
if (UrlLen > HTTP_URL_BUFFER_LEN) {
|
||||
Url = AllocateZeroPool (UrlLen);
|
||||
if (Url == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
FreePool (HttpInstance->Url);
|
||||
HttpInstance->Url = Url;
|
||||
}
|
||||
|
||||
UnicodeStrToAsciiStr (Request->Url, Url);
|
||||
UrlParser = NULL;
|
||||
@@ -347,7 +353,6 @@ EfiHttpRequest (
|
||||
|
||||
Wrap->TcpWrap.Method = Request->Method;
|
||||
|
||||
FreePool (Url);
|
||||
FreePool (HostName);
|
||||
|
||||
//
|
||||
@@ -480,7 +485,6 @@ EfiHttpRequest (
|
||||
goto Error4;
|
||||
}
|
||||
|
||||
FreePool (Url);
|
||||
if (HostName != NULL) {
|
||||
FreePool (HostName);
|
||||
}
|
||||
@@ -520,9 +524,6 @@ Error2:
|
||||
}
|
||||
|
||||
Error1:
|
||||
if (Url != NULL) {
|
||||
FreePool (Url);
|
||||
}
|
||||
if (HostName != NULL) {
|
||||
FreePool (HostName);
|
||||
}
|
||||
|
Reference in New Issue
Block a user