diff options
author | Jim_Dailey@Dell.com <Jim_Dailey@Dell.com> | 2016-02-18 23:51:33 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2016-07-13 20:42:18 +0800 |
commit | 60717c3126a56f794c02b694c7e6ccbf14126b8c (patch) | |
tree | a5d1d466588fd2ab5b864b9bd356f750512937c6 /ShellPkg/Application/Shell | |
parent | e92f719caa7b2ea7c1e1e78abca14ad8fc48df1c (diff) | |
download | edk2-platforms-60717c3126a56f794c02b694c7e6ccbf14126b8c.tar.xz |
ShellPkg: Increase reallocation size for temp memory files
If data of any real size were to be piped from one command to another,
an inordinate amount of time could be taken up by reallocating memory
that is only 10 bytes bigger than what is currently needed. Also, this
could cause unwelcome memory fragmentation.
Added a define to control how much memory is reallocated beyond that
which is currently needed. Set it to 1K vs. the original 10 bytes.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jim Dailey <jim_dailey@dell.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit c8d9d0e2bd376cbbe6a37da786784e7fc736c7d9)
Diffstat (limited to 'ShellPkg/Application/Shell')
-rw-r--r-- | ShellPkg/Application/Shell/FileHandleWrappers.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/ShellPkg/Application/Shell/FileHandleWrappers.c b/ShellPkg/Application/Shell/FileHandleWrappers.c index a9117bee92..1a0c9992ab 100644 --- a/ShellPkg/Application/Shell/FileHandleWrappers.c +++ b/ShellPkg/Application/Shell/FileHandleWrappers.c @@ -18,6 +18,8 @@ #include "Shell.h"
#include "FileHandleInternal.h"
+#define MEM_WRITE_REALLOC_OVERHEAD 1024
+
/**
File style interface for console (Open).
@@ -1398,8 +1400,8 @@ FileInterfaceMemWrite( // Unicode
//
if ((UINTN)(MemFile->Position + (*BufferSize)) > (UINTN)(MemFile->BufferSize)) {
- MemFile->Buffer = ReallocatePool((UINTN)(MemFile->BufferSize), (UINTN)(MemFile->BufferSize) + (*BufferSize) + 10, MemFile->Buffer);
- MemFile->BufferSize += (*BufferSize) + 10;
+ MemFile->Buffer = ReallocatePool((UINTN)(MemFile->BufferSize), (UINTN)(MemFile->BufferSize) + (*BufferSize) + MEM_WRITE_REALLOC_OVERHEAD, MemFile->Buffer);
+ MemFile->BufferSize += (*BufferSize) + MEM_WRITE_REALLOC_OVERHEAD;
}
CopyMem(((UINT8*)MemFile->Buffer) + MemFile->Position, Buffer, *BufferSize);
MemFile->Position += (*BufferSize);
@@ -1415,8 +1417,8 @@ FileInterfaceMemWrite( }
AsciiSPrint(AsciiBuffer, *BufferSize, "%S", Buffer);
if ((UINTN)(MemFile->Position + AsciiStrSize(AsciiBuffer)) > (UINTN)(MemFile->BufferSize)) {
- MemFile->Buffer = ReallocatePool((UINTN)(MemFile->BufferSize), (UINTN)(MemFile->BufferSize) + AsciiStrSize(AsciiBuffer) + 10, MemFile->Buffer);
- MemFile->BufferSize += AsciiStrSize(AsciiBuffer) + 10;
+ MemFile->Buffer = ReallocatePool((UINTN)(MemFile->BufferSize), (UINTN)(MemFile->BufferSize) + AsciiStrSize(AsciiBuffer) + MEM_WRITE_REALLOC_OVERHEAD, MemFile->Buffer);
+ MemFile->BufferSize += AsciiStrSize(AsciiBuffer) + MEM_WRITE_REALLOC_OVERHEAD;
}
CopyMem(((UINT8*)MemFile->Buffer) + MemFile->Position, AsciiBuffer, AsciiStrSize(AsciiBuffer));
MemFile->Position += (*BufferSize / sizeof(CHAR16));
|