+/**\r
+ Reallocates a buffer of a specified memory type.\r
+\r
+ Allocates and zeros the number bytes specified by NewSize with the memmory type\r
+ specified by PoolType. If OldBuffer is not NULL, then the smaller of OldSize and \r
+ NewSize bytes are copied from OldBuffer to the newly allocated buffer, and \r
+ OldBuffer is freed. A pointer to the newly allocated buffer is returned. \r
+ If NewSize is 0, then a valid buffer of 0 size is returned. If there is not \r
+ enough memory remaining to satisfy the request, then NULL is returned.\r
+ \r
+ If OldBuffer is NULL, then ASSERT().\r
+ If NewSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
+ If OldSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
+\r
+ @param PoolType The type of pool to allocate.\r
+ @param OldSize The size, in bytes, of OldBuffer.\r
+ @param NewSize The size, in bytes, of the buffer to reallocate.\r
+ @param OldBuffer The buffer to copy to the allocated buffer. This is an optional \r
+ parameter that may be NULL.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+InternalReallocatePool (\r
+ IN EFI_MEMORY_TYPE PoolType, \r
+ IN UINTN OldSize,\r
+ IN UINTN NewSize,\r
+ IN VOID *OldBuffer OPTIONAL\r
+ )\r
+{\r
+ VOID *NewBuffer;\r
+\r
+ NewBuffer = AllocateZeroPool (NewSize);\r
+ if (NewBuffer != NULL && OldBuffer != NULL) {\r
+ CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize));\r
+ FreePool (OldBuffer);\r
+ }\r
+ return NewBuffer;\r
+}\r
+\r
+/**\r
+ Reallocates a buffer of type EfiBootServicesData.\r
+\r
+ Allocates and zeros the number bytes specified by NewSize with the memmory type\r
+ EfiBootServicesData. If OldBuffer is not NULL, then the smaller of OldSize and \r
+ NewSize bytes are copied from OldBuffer to the newly allocated buffer, and \r
+ OldBuffer is freed. A pointer to the newly allocated buffer is returned. \r
+ If NewSize is 0, then a valid buffer of 0 size is returned. If there is not \r
+ enough memory remaining to satisfy the request, then NULL is returned.\r
+ \r
+ If OldBuffer is NULL, then ASSERT().\r
+ If NewSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
+ If OldSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
+\r
+ @param OldSize The size, in bytes, of OldBuffer.\r
+ @param NewSize The size, in bytes, of the buffer to reallocate.\r
+ @param OldBuffer The buffer to copy to the allocated buffer. This is an optional \r
+ parameter that may be NULL.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ReallocatePool (\r
+ IN UINTN OldSize,\r
+ IN UINTN NewSize,\r
+ IN VOID *OldBuffer OPTIONAL\r
+ )\r
+{\r
+ return InternalReallocatePool (EfiBootServicesData, OldSize, NewSize, OldBuffer);\r
+}\r
+\r
+/**\r
+ Reallocates a buffer of type EfiRuntimeServicesData.\r
+\r
+ Allocates and zeros the number bytes specified by NewSize with the memmory type\r
+ EfiRuntimeServicesData. If OldBuffer is not NULL, then the smaller of OldSize and \r
+ NewSize bytes are copied from OldBuffer to the newly allocated buffer, and \r
+ OldBuffer is freed. A pointer to the newly allocated buffer is returned. \r
+ If NewSize is 0, then a valid buffer of 0 size is returned. If there is not \r
+ enough memory remaining to satisfy the request, then NULL is returned.\r
+\r
+ If OldBuffer is NULL, then ASSERT().\r
+ If NewSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
+ If OldSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
+\r
+ @param OldSize The size, in bytes, of OldBuffer.\r
+ @param NewSize The size, in bytes, of the buffer to reallocate.\r
+ @param OldBuffer The buffer to copy to the allocated buffer. This is an optional \r
+ parameter that may be NULL.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ReallocateRuntimePool (\r
+ IN UINTN OldSize,\r
+ IN UINTN NewSize,\r
+ IN VOID *OldBuffer OPTIONAL\r
+ )\r
+{\r
+ return InternalReallocatePool (EfiRuntimeServicesData, OldSize, NewSize, OldBuffer);\r
+}\r
+\r
+/**\r
+ Reallocates a buffer of type EfiReservedMemoryType.\r
+\r
+ Allocates and zeros the number bytes specified by NewSize with the memmory type\r
+ EfiReservedMemoryType. If OldBuffer is not NULL, then the smaller of OldSize and \r
+ NewSize bytes are copied from OldBuffer to the newly allocated buffer, and \r
+ OldBuffer is freed. A pointer to the newly allocated buffer is returned. \r
+ If NewSize is 0, then a valid buffer of 0 size is returned. If there is not \r
+ enough memory remaining to satisfy the request, then NULL is returned.\r
+ \r
+ If OldBuffer is NULL, then ASSERT().\r
+ If NewSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
+ If OldSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). \r
+\r
+ @param OldSize The size, in bytes, of OldBuffer.\r
+ @param NewSize The size, in bytes, of the buffer to reallocate.\r
+ @param OldBuffer The buffer to copy to the allocated buffer. This is an optional \r
+ parameter that may be NULL.\r
+\r
+ @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+ReallocateReservedPool (\r
+ IN UINTN OldSize,\r
+ IN UINTN NewSize,\r
+ IN VOID *OldBuffer OPTIONAL\r
+ )\r
+{\r
+ return InternalReallocatePool (EfiReservedMemoryType, OldSize, NewSize, OldBuffer);\r
+}\r
+\r