]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/Common/MyAlloc.c
BaseTools: Clean up source files
[mirror_edk2.git] / BaseTools / Source / C / Common / MyAlloc.c
index b53713941cdbc1f8e57dca0a8d205468c89caf7a..4b656ed39c8c3309062c63de51dd543b42784688 100644 (file)
@@ -1,21 +1,14 @@
 /** @file\r
+File for memory allocation tracking functions.\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
 \r
-Module Name:\r
-\r
-  MyAlloc.c\r
-\r
-Abstract:\r
-\r
-  File for memory allocation tracking functions.\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
 **/\r
 \r
@@ -80,13 +73,24 @@ MyCheck (
   //\r
   // Check parameters.\r
   //\r
-  if (File == NULL || Line == 0) {\r
+  if (File == NULL) {\r
+    printf (\r
+      "\nMyCheck(Final=%u, File=NULL, Line=%u)"\r
+      "Invalid parameter(s).\n",\r
+      Final,\r
+      (unsigned)Line\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+\r
+  if (Line == 0) {\r
     printf (\r
       "\nMyCheck(Final=%u, File=%s, Line=%u)"\r
       "Invalid parameter(s).\n",\r
       Final,\r
       File,\r
-      (UINT32)Line\r
+      (unsigned)Line\r
       );\r
 \r
     exit (1);\r
@@ -98,7 +102,7 @@ MyCheck (
       "Invalid parameter.\n",\r
       Final,\r
       File,\r
-      (UINT32)Line\r
+      (unsigned)Line\r
       );\r
 \r
     exit (1);\r
@@ -121,12 +125,12 @@ MyCheck (
       "\nFile=%s, Line=%u, nSize=%u, Head=%xh, Tail=%xh\n",\r
       Final,\r
       File,\r
-      (UINT32)Line,\r
+      (unsigned)Line,\r
       Tmp->File,\r
-      (UINT32)Tmp->Line,\r
-      (UINT32)Tmp->Size,\r
-      *(UINT32 *) (Tmp->Buffer),\r
-      *(UINT32 *) (&Tmp->Buffer[Tmp->Size + sizeof (UINT32)])\r
+      (unsigned) Tmp->Line,\r
+      (unsigned) Tmp->Size,\r
+      (unsigned) *(UINT32 *) (Tmp->Buffer),\r
+      (unsigned) *(UINT32 *) (&Tmp->Buffer[Tmp->Size + sizeof (UINT32)])\r
       );\r
 \r
     exit (1);\r
@@ -141,17 +145,17 @@ MyCheck (
         "\nSome allocated items have not been freed.\n",\r
         Final,\r
         File,\r
-        (UINT32)Line\r
+        (unsigned)Line\r
         );\r
 \r
       for (Tmp = MyAllocData; Tmp != NULL; Tmp = Tmp->Next) {\r
         printf (\r
           "File=%s, Line=%u, nSize=%u, Head=%xh, Tail=%xh\n",\r
           Tmp->File,\r
-          (UINT32)Tmp->Line,\r
-          (UINT32)Tmp->Size,\r
-          *(UINT32 *) (Tmp->Buffer),\r
-          *(UINT32 *) (&Tmp->Buffer[Tmp->Size + sizeof (UINT32)])\r
+          (unsigned) Tmp->Line,\r
+          (unsigned) Tmp->Size,\r
+          (unsigned) *(UINT32 *) (Tmp->Buffer),\r
+          (unsigned) *(UINT32 *) (&Tmp->Buffer[Tmp->Size + sizeof (UINT32)])\r
           );\r
       }\r
     }\r
@@ -197,13 +201,24 @@ MyAlloc (
   //\r
   // Check for invalid parameters.\r
   //\r
-  if (Size == 0 || File == NULL || Line == 0) {\r
+  if (File == NULL) {\r
+    printf (\r
+      "\nMyAlloc(Size=%u, File=NULL, Line=%u)"\r
+      "\nInvalid parameter(s).\n",\r
+      (unsigned)Size,\r
+      (unsigned)Line\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+\r
+  if (Size == 0 || Line == 0) {\r
     printf (\r
       "\nMyAlloc(Size=%u, File=%s, Line=%u)"\r
       "\nInvalid parameter(s).\n",\r
-      (UINT32)Size,\r
+      (unsigned)Size,\r
       File,\r
-      (UINT32)Line\r
+      (unsigned)Line\r
       );\r
 \r
     exit (1);\r
@@ -214,9 +229,9 @@ MyAlloc (
     printf (\r
       "\nMyAlloc(Size=%u, File=%s, Line=%u)"\r
       "\nInvalid parameter.\n",\r
-      (UINT32)Size,\r
+      (unsigned)Size,\r
       File,\r
-      (UINT32)Line\r
+      (unsigned)Line\r
       );\r
 \r
     exit (1);\r
@@ -238,9 +253,9 @@ MyAlloc (
     printf (\r
       "\nMyAlloc(Size=%u, File=%s, Line=%u)"\r
       "\nOut of memory.\n",\r
-      (UINT32)Size,\r
+      (unsigned)Size,\r
       File,\r
-      (UINT32)Line\r
+      (unsigned)Line\r
       );\r
 \r
     exit (1);\r
@@ -310,14 +325,26 @@ MyRealloc (
   //\r
   // Check for invalid parameter(s).\r
   //\r
-  if (Size == 0 || File == NULL || Line == 0) {\r
+  if (File == NULL) {\r
+    printf (\r
+      "\nMyRealloc(Ptr=%p, Size=%u, File=NULL, Line=%u)"\r
+      "\nInvalid parameter(s).\n",\r
+      Ptr,\r
+      (unsigned)Size,\r
+      (unsigned)Line\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+\r
+  if (Size == 0 || Line == 0) {\r
     printf (\r
       "\nMyRealloc(Ptr=%p, Size=%u, File=%s, Line=%u)"\r
       "\nInvalid parameter(s).\n",\r
       Ptr,\r
-      (UINT32)Size,\r
+      (unsigned)Size,\r
       File,\r
-      (UINT32)Line\r
+      (unsigned)Line\r
       );\r
 \r
     exit (1);\r
@@ -328,9 +355,9 @@ MyRealloc (
       "\nMyRealloc(Ptr=%p, Size=%u, File=%s, Line=%u)"\r
       "\nInvalid parameter.\n",\r
       Ptr,\r
-      (UINT32)Size,\r
+      (unsigned)Size,\r
       File,\r
-      (UINT32)Line\r
+      (unsigned)Line\r
       );\r
 \r
     exit (1);\r
@@ -349,9 +376,9 @@ MyRealloc (
           "\nMyRealloc(Ptr=%p, Size=%u, File=%s, Line=%u)"\r
           "\nCould not find buffer.\n",\r
           Ptr,\r
-          (UINT32)Size,\r
+          (unsigned)Size,\r
           File,\r
-          (UINT32)Line\r
+          (unsigned)Line\r
           );\r
 \r
         exit (1);\r
@@ -415,13 +442,24 @@ MyFree (
   //\r
   // Check for invalid parameter(s).\r
   //\r
-  if (File == NULL || Line == 0) {\r
+  if (File == NULL) {\r
+    printf (\r
+      "\nMyFree(Ptr=%p, File=NULL, Line=%u)"\r
+      "\nInvalid parameter(s).\n",\r
+      Ptr,\r
+      (unsigned)Line\r
+      );\r
+\r
+    exit (1);\r
+  }\r
+\r
+  if (Line == 0) {\r
     printf (\r
       "\nMyFree(Ptr=%p, File=%s, Line=%u)"\r
       "\nInvalid parameter(s).\n",\r
       Ptr,\r
       File,\r
-      (UINT32)Line\r
+      (unsigned)Line\r
       );\r
 \r
     exit (1);\r
@@ -433,7 +471,7 @@ MyFree (
       "\nInvalid parameter.\n",\r
       Ptr,\r
       File,\r
-      (UINT32)Line\r
+      (unsigned)Line\r
       );\r
 \r
     exit (1);\r
@@ -453,7 +491,7 @@ MyFree (
       "\nCalled before memory allocated.\n",\r
       Ptr,\r
       File,\r
-      (UINT32)Line\r
+      (unsigned)Line\r
       );\r
 \r
     exit (1);\r
@@ -486,7 +524,7 @@ MyFree (
           "\nNot found.\n",\r
           Ptr,\r
           File,\r
-          (UINT32)Line\r
+          (unsigned)Line\r
           );\r
 \r
         exit (1);\r