-/**\r
- Helper function called as part of the code needed\r
- to allocate the proper sized buffer for various\r
- EFI interfaces.\r
-\r
- @param Status Current status\r
- @param Buffer Current allocated buffer, or NULL\r
- @param BufferSize Current buffer size needed\r
-\r
- @retval TRUE if the buffer was reallocated and the caller\r
- should try the API again.\r
- @retval FALSE buffer could not be allocated and the caller\r
- should not try the API again.\r
-\r
-**/\r
-BOOLEAN\r
-CoreGrowBuffer (\r
- IN OUT EFI_STATUS *Status,\r
- IN OUT VOID **Buffer,\r
- IN UINTN BufferSize\r
- )\r
-{\r
- BOOLEAN TryAgain;\r
-\r
- TryAgain = FALSE;\r
- //\r
- // If this is an initial request, buffer will be null with a new buffer size\r
- //\r
- if (*Buffer == NULL) {\r
- *Status = EFI_BUFFER_TOO_SMALL;\r
- }\r
-\r
- if (BufferSize == 0) {\r
- return TRUE;\r
- }\r
-\r
- //\r
- // If the status code is "buffer too small", resize the buffer\r
- //\r
- if (*Status == EFI_BUFFER_TOO_SMALL) {\r
- if (*Buffer != NULL) {\r
- CoreFreePool (*Buffer);\r
- }\r
-\r
- *Buffer = AllocatePool (BufferSize);\r
- if (*Buffer != NULL) {\r
- TryAgain = TRUE;\r
- } else {\r
- *Status = EFI_OUT_OF_RESOURCES;\r
- }\r
- }\r
-\r
- //\r
- // If there's an error, free the buffer\r
- //\r
- if ((!TryAgain) && (EFI_ERROR (*Status)) && (*Buffer != NULL)) {\r
- CoreFreePool (*Buffer);\r
- *Buffer = NULL;\r
- }\r
-\r
- return TryAgain;\r
-}\r
-\r
-\r