This patch is to make sure at least VARIABLE_RECLAIM_THRESHOLD (1024) bytes of spaces...
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 10 Oct 2006 02:21:51 +0000 (02:21 +0000)
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 10 Oct 2006 02:21:51 +0000 (02:21 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1697 6f19259b-4bc3-4df7-8a09-765794883524

EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c
EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.h

index a9505d9..d575417 100644 (file)
@@ -1388,6 +1388,23 @@ Returns:
 \r
     mVariableModuleGlobal->NonVolatileLastVariableOffset = (UINTN) NextVariable - (UINTN) CurrPtr;\r
 \r
+    //\r
+    // Check if the free area is blow a threshold\r
+    //\r
+    if ((((VARIABLE_STORE_HEADER *)((UINTN) CurrPtr))->Size - mVariableModuleGlobal->NonVolatileLastVariableOffset) < VARIABLE_RECLAIM_THRESHOLD) {\r
+      Status = Reclaim (\r
+                mVariableModuleGlobal->VariableBase[Physical].NonVolatileVariableBase,\r
+                &mVariableModuleGlobal->NonVolatileLastVariableOffset,\r
+                FALSE\r
+                );\r
+    }\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      gBS->FreePool (mVariableModuleGlobal);\r
+      gBS->FreePool (VolatileVariableStore);\r
+      return Status;\r
+    }\r
+\r
     //\r
     // Check if the free area is really free.\r
     //\r
index 55423a2..014df50 100644 (file)
@@ -35,6 +35,7 @@ Abstract:
 #define ALIGNMENT  1\r
 #endif\r
 \r
+#define VARIABLE_RECLAIM_THRESHOLD (1024)\r
 \r
 #define VARIABLE_STORE_SIZE (64 * 1024)\r
 #define SCRATCH_SIZE        (4 * 1024)\r