mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-30 09:04:07 +02:00
Update to use ReallocatePool() from BaseMemoryLib
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6677 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
7b3381a232
commit
d777486198
@ -15,42 +15,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
|
|
||||||
#include "InternalBdsLib.h"
|
#include "InternalBdsLib.h"
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
Adjusts the size of a previously allocated buffer.
|
|
||||||
|
|
||||||
@param OldPool A pointer to the buffer whose size is being adjusted.
|
|
||||||
@param OldSize The size of the current buffer.
|
|
||||||
@param NewSize The size of the new buffer.
|
|
||||||
|
|
||||||
@return The new buffer allocated. If allocatio failed, NULL will be returned.
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID *
|
|
||||||
ReallocatePool (
|
|
||||||
IN VOID *OldPool,
|
|
||||||
IN UINTN OldSize,
|
|
||||||
IN UINTN NewSize
|
|
||||||
)
|
|
||||||
{
|
|
||||||
VOID *NewPool;
|
|
||||||
|
|
||||||
NewPool = NULL;
|
|
||||||
if (NewSize != 0) {
|
|
||||||
NewPool = AllocateZeroPool (NewSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OldPool != NULL) {
|
|
||||||
if (NewPool != NULL) {
|
|
||||||
CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
FreePool (OldPool);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NewPool;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Concatenates a formatted unicode string to allocated pool.
|
Concatenates a formatted unicode string to allocated pool.
|
||||||
The caller must free the resulting buffer.
|
The caller must free the resulting buffer.
|
||||||
@ -95,9 +59,9 @@ CatPrint (
|
|||||||
StringSize += (StrSize (Str->str) - sizeof (UINT16));
|
StringSize += (StrSize (Str->str) - sizeof (UINT16));
|
||||||
|
|
||||||
Str->str = ReallocatePool (
|
Str->str = ReallocatePool (
|
||||||
Str->str,
|
|
||||||
StrSize (Str->str),
|
StrSize (Str->str),
|
||||||
StringSize
|
StringSize,
|
||||||
|
Str->str
|
||||||
);
|
);
|
||||||
ASSERT (Str->str != NULL);
|
ASSERT (Str->str != NULL);
|
||||||
}
|
}
|
||||||
@ -1523,7 +1487,7 @@ DevicePathToStr (
|
|||||||
|
|
||||||
Done:
|
Done:
|
||||||
NewSize = (Str.len + 1) * sizeof (CHAR16);
|
NewSize = (Str.len + 1) * sizeof (CHAR16);
|
||||||
Str.str = ReallocatePool (Str.str, NewSize, NewSize);
|
Str.str = ReallocatePool (NewSize, NewSize, Str.str);
|
||||||
ASSERT (Str.str != NULL);
|
ASSERT (Str.str != NULL);
|
||||||
Str.str[Str.len] = 0;
|
Str.str[Str.len] = 0;
|
||||||
return Str.str;
|
return Str.str;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user