NetworkPkg: Avoid memory allocation for each HTTP message exchange.
[mirror_edk2.git] / NetworkPkg / HttpDxe / HttpProto.c
index e8ce9879f309d159a35e2f5f8e2d28b2a0a52dac..99f907e10c7f96e8598d90de41e1a0b6e27c9038 100644 (file)
@@ -431,6 +431,12 @@ HttpInitProtocol (
     goto ON_ERROR;\r
   }\r
 \r
+  HttpInstance->Url = AllocateZeroPool (HTTP_URL_BUFFER_LEN);\r
+  if (HttpInstance->Url == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto ON_ERROR;\r
+  }\r
+\r
   NetMapInit (&HttpInstance->TxTokens);\r
   NetMapInit (&HttpInstance->RxTokens);\r
 \r
@@ -496,6 +502,11 @@ HttpCleanProtocol (
     HttpInstance->MsgParser = NULL;\r
   }\r
 \r
+  if (HttpInstance->Url != NULL) {\r
+    FreePool (HttpInstance->Url);\r
+    HttpInstance->Url = NULL;\r
+  }\r
+\r
   NetMapClean (&HttpInstance->TxTokens);\r
   NetMapClean (&HttpInstance->RxTokens);\r
 \r