Commit in reactos/apps/utils/pnpdump on MAIN
pnpdump.c+21-121.8 -> 1.9
Dynamically resize buffer as needed

reactos/apps/utils/pnpdump
pnpdump.c 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- pnpdump.c	25 Dec 2004 11:22:36 -0000	1.8
+++ pnpdump.c	26 Dec 2004 23:31:00 -0000	1.9
@@ -706,7 +706,7 @@
     }
 
   /* Allocate buffer */
-  dwSize = 1024;
+  dwSize = 2048;
   lpBuffer = malloc(dwSize);
   if (lpBuffer == NULL)
     {
@@ -715,19 +715,28 @@
       return 0;
     }
 
-  lError = RegQueryValueEx(hPnpKey,
-			   "Configuration Data",
-			   NULL,
-			   &dwType,
-			   (LPBYTE)lpBuffer,
-			   &dwSize);
-  if (lError != ERROR_SUCCESS)
+  do
     {
+      lError = RegQueryValueEx(hPnpKey,
+			       "Configuration Data",
+			       NULL,
+			       &dwType,
+			       (LPBYTE)lpBuffer,
+			       &dwSize);
       if (lError == ERROR_MORE_DATA)
-	{
-	  printf("Need to resize buffer to %lu\n", dwSize);
-	}
-
+        {
+          lpBuffer = realloc(lpBuffer, dwSize);
+          if (lpBuffer == NULL)
+            {
+              printf("Error: realloc() of %u bytes failed\n", (unsigned) dwSize);
+              RegCloseKey(hPnpKey);
+              return 0;
+            }
+        }
+    }
+  while (lError == ERROR_MORE_DATA);
+  if (lError != ERROR_SUCCESS)
+    {
       printf("Failed to read 'Configuration Data' value\n");
       free(lpBuffer);
       RegCloseKey(hPnpKey);
CVSspam 0.2.8