[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-user: Removing My* memory alllocation functions



Note that the second patch gets my test PCB loading again, but does not
consider every possible case.

Before committing, these MUST be squashed, but it is convenient to keep
them separate for now.

Thinking about it, a pre-patch converting all "safe" MyStrdup calls to
plain "strdup" would probably be best, then the MyStrdup -> WHATEVER can
be purely mechanical along with the rest of the mechanical patch.

Best regards,

-- 
Peter Clifton

Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA

Tel: +44 (0)7729 980173 - (No signal in the lab!)
Tel: +44 (0)1223 748328 - (Shared lab phone, ask for me)
From a3c35de3fa4a543817c633cf99487d62989e4d1f Mon Sep 17 00:00:00 2001
From: Peter Clifton <pcjc2@xxxxxxxxx>
Date: Tue, 7 Dec 2010 01:47:28 +0000
Subject: [PATCH 1/2] Remove My* memory allocation routines

Lets just use the standard APIs directly
---
 src/action.c                  |   12 +-
 src/buffer.c                  |   13 +-
 src/command.c                 |    2 +-
 src/copy.c                    |    2 +-
 src/create.c                  |   53 ++++-----
 src/drill.c                   |   29 +++--
 src/file.c                    |   34 +++---
 src/find.c                    |   43 +++----
 src/fontmode.c                |    8 +-
 src/hid/common/flags.c        |    2 +-
 src/hid/gerber/gerber.c       |    6 +-
 src/hid/gtk/gtkhid-gdk.c      |    6 +-
 src/hid/gtk/gui-dialog-size.c |    2 +-
 src/hid/gtk/gui-top-window.c  |    4 +-
 src/hid/lesstif/main.c        |    5 +-
 src/hid/lesstif/menu.c        |    4 +-
 src/hid/lesstif/styles.c      |    3 +-
 src/intersect.c               |   11 +-
 src/main.c                    |    6 +-
 src/misc.c                    |   20 ++--
 src/move.c                    |    2 +-
 src/mymem.c                   |  277 ++++++++++-------------------------------
 src/mymem.h                   |    7 -
 src/netlist.c                 |    6 +-
 src/parse_l.l                 |    5 +-
 src/parse_y.y                 |   82 ++++++------
 src/rats.c                    |   25 ++--
 src/remove.c                  |    8 +-
 src/report.c                  |    2 +-
 src/undo.c                    |   10 +-
 30 files changed, 254 insertions(+), 435 deletions(-)

diff --git a/src/action.c b/src/action.c
index f52fcf4..e03026f 100644
--- a/src/action.c
+++ b/src/action.c
@@ -5730,8 +5730,8 @@ ActionSaveTo (int argc, char **argv, int x, int y)
 
   if (strcasecmp (function, "LayoutAs") == 0)
     {
-      MYFREE (PCB->Filename);
-      PCB->Filename = MyStrdup (name, __FUNCTION__);
+      free (PCB->Filename);
+      PCB->Filename = strdup (name);
       SavePCB (PCB->Filename);
       return 0;
     }
@@ -5890,7 +5890,7 @@ ActionLoadFrom (int argc, char **argv, int x, int y)
   else if (strcasecmp (function, "Netlist") == 0)
     {
       if (PCB->Netlistname)
-	SaveFree (PCB->Netlistname);
+	free (PCB->Netlistname);
       PCB->Netlistname = StripWhiteSpaceAndDup (name);
       FreeLibraryMemory (&PCB->NetlistLib);
       if (!ImportNetlist (PCB->Netlistname))
@@ -5929,7 +5929,7 @@ ActionNew (int argc, char **argv, int x, int y)
   if (!PCB->Changed || gui->confirm_dialog (_("OK to clear layout data?"), 0))
     {
       if (name)
-	name = MyStrdup (name, "ActionNew");
+	name = strdup (name);
       else
 	name = gui->prompt_for (_("Enter the layout name:"), "");
 
@@ -7237,8 +7237,8 @@ ActionElementSetAttr (int argc, char **argv, int x, int y)
 
   if (attr && value)
     {
-      MYFREE (attr->value);
-      attr->value = MyStrdup (value, "ElementSetAttr");
+      free (attr->value);
+      attr->value = strdup (value);
     }
   if (attr && ! value)
     {
diff --git a/src/buffer.c b/src/buffer.c
index 1b2d27c..0c132e5 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -153,7 +153,7 @@ AddLineToBuffer (LayerTypePtr Layer, LineTypePtr Line)
 			       MaskFlags (Line->Flags,
 					  FOUNDFLAG | ExtraFlag));
   if (line && Line->Number)
-    line->Number = MyStrdup (Line->Number, "AddLineToBuffer");
+    line->Number = strdup (Line->Number);
   return (line);
 }
 
@@ -943,7 +943,7 @@ SmashBufferElement (BufferTypePtr Buffer)
 			  line->Point2.X, line->Point2.Y,
 			  line->Thickness, 0, NoFlags ());
     if (line)
-      line->Number = MyStrdup (NAMEONPCB_NAME (element), "SmashBuffer");
+      line->Number = strdup (NAMEONPCB_NAME (element));
   }
   END_LOOP;
   ARC_LOOP (element);
@@ -981,11 +981,11 @@ SmashBufferElement (BufferTypePtr Buffer)
 				 pad->Point2.X, pad->Point2.Y,
 				 pad->Thickness, pad->Clearance, NoFlags ());
     if (line)
-      line->Number = MyStrdup (pad->Number, "SmashBuffer");
+      line->Number = strdup (pad->Number);
   }
   END_LOOP;
   FreeElementMemory (element);
-  SaveFree (element);
+  free (element);
   return (true);
 }
 
@@ -1154,8 +1154,7 @@ ConvertBufferToElement (BufferTypePtr Buffer)
   LINE_LOOP (&Buffer->Data->SILKLAYER);
   {
     if (line->Number && !NAMEONPCB_NAME (Element))
-      NAMEONPCB_NAME (Element) = MyStrdup (line->Number,
-					   "ConvertBufferToElement");
+      NAMEONPCB_NAME (Element) = strdup (line->Number);
     CreateNewLineInElement (Element, line->Point1.X,
 			    line->Point1.Y, line->Point2.X,
 			    line->Point2.Y, line->Thickness);
@@ -1207,7 +1206,7 @@ LoadLayoutToBuffer (BufferTypePtr Buffer, char *Filename)
     {
       /* clear data area and replace pointer */
       ClearBuffer (Buffer);
-      SaveFree (Buffer->Data);
+      free (Buffer->Data);
       Buffer->Data = newPCB->Data;
       newPCB->Data = NULL;
       Buffer->X = newPCB->CursorX;
diff --git a/src/command.c b/src/command.c
index b41263b..5c2b985 100644
--- a/src/command.c
+++ b/src/command.c
@@ -297,7 +297,7 @@ CommandLoadNetlist (int argc, char **argv, int x, int y)
       return (1);
     }
   if (PCB->Netlistname)
-    SaveFree (PCB->Netlistname);
+    free (PCB->Netlistname);
   PCB->Netlistname = StripWhiteSpaceAndDup (filename);
   free (name);
   return (0);
diff --git a/src/copy.c b/src/copy.c
index c8244ed..ee831b9 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -220,7 +220,7 @@ CopyLine (LayerTypePtr Layer, LineTypePtr Line)
   if (!line)
     return (line);
   if (Line->Number)
-    line->Number = MyStrdup (Line->Number, "CopyLine");
+    line->Number = strdup (Line->Number);
   DrawLine (Layer, line, 0);
   AddObjectToCreateUndoList (LINE_TYPE, Layer, line, line);
   return (line);
diff --git a/src/create.c b/src/create.c
index bf3b688..c965ac3 100644
--- a/src/create.c
+++ b/src/create.c
@@ -80,7 +80,7 @@ DataTypePtr
 CreateNewBuffer (void)
 {
   DataTypePtr data;
-  data = (DataTypePtr) MyCalloc (1, sizeof (DataType), "CreateNewBuffer()");
+  data = (DataTypePtr) calloc (1, sizeof (DataType));
   data->pcb = (void *) PCB;
   return data;
 }
@@ -136,7 +136,7 @@ CreateNewPCB (bool SetDefaultNames)
   int i;
 
   /* allocate memory, switch all layers on and copy resources */
-  ptr = MyCalloc (1, sizeof (PCBType), "CreateNewPCB()");
+  ptr = calloc (1, sizeof (PCBType));
   ptr->Data = CreateNewBuffer ();
   ptr->Data->pcb = (void *) ptr;
 
@@ -193,8 +193,7 @@ CreateNewPCB (bool SetDefaultNames)
   ptr->minRing = Settings.minRing;
 
   for (i = 0; i < MAX_LAYER; i++)
-    ptr->Data->Layer[i].Name = MyStrdup (Settings.DefaultLayerName[i],
-					 "CreateNewPCB()");
+    ptr->Data->Layer[i].Name = strdup (Settings.DefaultLayerName[i]);
 
   return (ptr);
 }
@@ -213,10 +212,8 @@ CreateNewPCBPost (PCBTypePtr pcb, int use_defaults)
       if (ParseGroupString (Settings.Groups, &pcb->LayerGroups, DEF_LAYER))
 	return 1;
 
-      pcb->Data->Layer[component_silk_layer].Name =
-	MyStrdup ("silk", "CreateNewPCB()");
-      pcb->Data->Layer[solder_silk_layer].Name =
-	MyStrdup ("silk", "CreateNewPCB()");
+      pcb->Data->Layer[component_silk_layer].Name = strdup ("silk");
+      pcb->Data->Layer[solder_silk_layer].Name = strdup ("silk");
     }
   return 0;
 }
@@ -262,7 +259,7 @@ CreateNewVia (DataTypePtr Data,
 	       0.01 * Via->DrillingHole, 0.01 * DrillingHole);
     }
 
-  Via->Name = MyStrdup (Name, "CreateNewVia()");
+  Via->Name = strdup (Name);
   Via->Flags = Flags;
   CLEAR_FLAG (WARNFLAG, Via);
   SET_FLAG (VIAFLAG, Via);
@@ -590,7 +587,7 @@ CreateNewText (LayerTypePtr Layer, FontTypePtr PCBFont,
   text->Direction = Direction;
   text->Flags = Flags;
   text->Scale = Scale;
-  text->TextString = MyStrdup (TextString, "CreateNewText()");
+  text->TextString = strdup (TextString);
 
   /* calculate size of the bounding box */
   SetTextBoundingBox (PCBFont, text);
@@ -702,8 +699,7 @@ CreateNewArcInElement (ElementTypePtr Element,
   if (Element->ArcN >= Element->ArcMax)
     {
       Element->ArcMax += STEP_ELEMENTARC;
-      arc = MyRealloc (arc, Element->ArcMax * sizeof (ArcType),
-		       "CreateNewArcInElement()");
+      arc = realloc (arc, Element->ArcMax * sizeof (ArcType));
       Element->Arc = arc;
       memset (arc + Element->ArcN, 0, STEP_ELEMENTARC * sizeof (ArcType));
     }
@@ -749,8 +745,7 @@ CreateNewLineInElement (ElementTypePtr Element,
   if (Element->LineN >= Element->LineMax)
     {
       Element->LineMax += STEP_ELEMENTLINE;
-      line = MyRealloc (line, Element->LineMax * sizeof (LineType),
-			"CreateNewLineInElement()");
+      line = realloc (line, Element->LineMax * sizeof (LineType));
       Element->Line = line;
       memset (line + Element->LineN, 0, STEP_ELEMENTLINE * sizeof (LineType));
     }
@@ -785,8 +780,8 @@ CreateNewPin (ElementTypePtr Element,
   pin->Thickness = Thickness;
   pin->Clearance = Clearance;
   pin->Mask = Mask;
-  pin->Name = MyStrdup (Name, "CreateNewPin()");
-  pin->Number = MyStrdup (Number, "CreateNewPin()");
+  pin->Name = strdup (Name);
+  pin->Number = strdup (Number);
   pin->Flags = Flags;
   CLEAR_FLAG (WARNFLAG, pin);
   SET_FLAG (PINFLAG, pin);
@@ -872,8 +867,8 @@ CreateNewPad (ElementTypePtr Element,
   pad->Thickness = Thickness;
   pad->Clearance = Clearance;
   pad->Mask = Mask;
-  pad->Name = MyStrdup (Name, "CreateNewPad()");
-  pad->Number = MyStrdup (Number, "CreateNewPad()");
+  pad->Name = strdup (Name);
+  pad->Number = strdup (Number);
   pad->Flags = Flags;
   CLEAR_FLAG (WARNFLAG, pad);
   pad->ID = ID++;
@@ -890,14 +885,13 @@ AddTextToElement (TextTypePtr Text, FontTypePtr PCBFont,
 		  LocationType X, LocationType Y,
 		  BYTE Direction, char *TextString, int Scale, FlagType Flags)
 {
-  MYFREE (Text->TextString);
+  free (Text->TextString);
+  Text->TextString = (TextString && *TextString) ? strdup (TextString) : NULL;
   Text->X = X;
   Text->Y = Y;
   Text->Direction = Direction;
   Text->Flags = Flags;
   Text->Scale = Scale;
-  Text->TextString = (TextString && *TextString) ?
-    MyStrdup (TextString, "AddTextToElement()") : NULL;
 
   /* calculate size of the bounding box */
   SetTextBoundingBox (PCBFont, Text);
@@ -918,8 +912,7 @@ CreateNewLineInSymbol (SymbolTypePtr Symbol,
   if (Symbol->LineN >= Symbol->LineMax)
     {
       Symbol->LineMax += STEP_SYMBOLLINE;
-      line = MyRealloc (line, Symbol->LineMax * sizeof (LineType),
-			"CreateNewLineInSymbol()");
+      line = realloc (line, Symbol->LineMax * sizeof (LineType));
       Symbol->Line = line;
       memset (line + Symbol->LineN, 0, STEP_SYMBOLLINE * sizeof (LineType));
     }
@@ -976,12 +969,12 @@ CreateNewNet (LibraryTypePtr lib, char *name, char *style)
 
   sprintf (temp, "  %s", name);
   menu = GetLibraryMenuMemory (lib);
-  menu->Name = MyStrdup (temp, "CreateNewNet()");
+  menu->Name = strdup (temp);
   menu->flag = 1;		/* net is enabled by default */
   if (style == NULL || NSTRCMP ("(unknown)", style) == 0)
     menu->Style = NULL;
   else
-    menu->Style = MyStrdup (style, "CreateNewNet()");
+    menu->Style = strdup (style);
   return (menu);
 }
 
@@ -993,7 +986,7 @@ CreateNewConnection (LibraryMenuTypePtr net, char *conn)
 {
   LibraryEntryTypePtr entry = GetLibraryEntryMemory (net);
 
-  entry->ListEntry = MyStrdup (conn, "CreateNewConnection()");
+  entry->ListEntry = strdup (conn);
   return (entry);
 }
 
@@ -1006,12 +999,10 @@ CreateNewAttribute (AttributeListTypePtr list, char *name, char *value)
   if (list->Number >= list->Max)
     {
       list->Max += 10;
-      list->List = MyRealloc (list->List,
-			      list->Max * sizeof (AttributeType),
-			      "CreateNewAttribute");
+      list->List = realloc (list->List, list->Max * sizeof (AttributeType));
     }
-  list->List[list->Number].name = MyStrdup (name, "CreateNewAttribute");
-  list->List[list->Number].value = MyStrdup (value, "CreateNewAttribute");
+  list->List[list->Number].name = strdup (name);
+  list->List[list->Number].value = strdup (value);
   list->Number++;
   return &list->List[list->Number - 1];
 }
diff --git a/src/drill.c b/src/drill.c
index 738ed18..1f1d770 100644
--- a/src/drill.c
+++ b/src/drill.c
@@ -126,7 +126,7 @@ GetDrillInfo (DataTypePtr top)
   bool DrillFound = false;
   bool NewDrill;
 
-  AllDrills = MyCalloc (1, sizeof (DrillInfoType), "GetAllDrillInfo()");
+  AllDrills = calloc (1, sizeof (DrillInfoType));
   ALLPIN_LOOP (top);
   {
     if (!DrillFound)
@@ -235,10 +235,9 @@ RoundDrillInfo (DrillInfoTypePtr d, int roundto)
 	    = d->Drill[i].ElementN + d->Drill[i+1].ElementN;
 	  if (d->Drill[i].ElementMax)
 	    {
-	      d->Drill[i].Element = MyRealloc (d->Drill[i].Element,
-					       d->Drill[i].ElementMax *
-					       sizeof(ElementTypePtr),
-					       "RoundDrillInfo");
+	      d->Drill[i].Element = realloc (d->Drill[i].Element,
+					     d->Drill[i].ElementMax *
+					     sizeof (ElementTypePtr));
 
 	      for (ei = 0; ei < d->Drill[i+1].ElementN; ei++)
 		{
@@ -250,16 +249,18 @@ RoundDrillInfo (DrillInfoTypePtr d, int roundto)
 		      = d->Drill[i + 1].Element[ei];
 		}
 	    }
-	  MYFREE (d->Drill[i + 1].Element);
+	  free (d->Drill[i + 1].Element);
+	  d->Drill[i + 1].Element = NULL;
 
 	  d->Drill[i].PinMax = d->Drill[i].PinN + d->Drill[i + 1].PinN;
-	  d->Drill[i].Pin = MyRealloc (d->Drill[i].Pin,
-				       d->Drill[i].PinMax *
-				       sizeof (PinTypePtr), "RoundDrillInfo");
+	  d->Drill[i].Pin = realloc (d->Drill[i].Pin,
+				     d->Drill[i].PinMax *
+				     sizeof (PinTypePtr));
 	  memcpy (d->Drill[i].Pin + d->Drill[i].PinN, d->Drill[i + 1].Pin,
 		  d->Drill[i + 1].PinN * sizeof (PinTypePtr));
 	  d->Drill[i].PinN += d->Drill[i + 1].PinN;
-	  MYFREE (d->Drill[i + 1].Pin);
+	  free (d->Drill[i + 1].Pin);
+	  d->Drill[i + 1].Pin = NULL;
 
 	  d->Drill[i].PinCount += d->Drill[i + 1].PinCount;
 	  d->Drill[i].ViaCount += d->Drill[i + 1].ViaCount;
@@ -285,10 +286,10 @@ FreeDrillInfo (DrillInfoTypePtr Drills)
 {
   DRILL_LOOP (Drills);
   {
-    MYFREE (drill->Element);
-    MYFREE (drill->Pin);
+    free (drill->Element);
+    free (drill->Pin);
   }
   END_LOOP;
-  MYFREE (Drills->Drill);
-  SaveFree (Drills);
+  free (Drills->Drill);
+  free (Drills);
 }
diff --git a/src/file.c b/src/file.c
index 6893379..b8c16ea 100644
--- a/src/file.c
+++ b/src/file.c
@@ -318,8 +318,8 @@ SavePCB (char *Filename)
        * first of all make a copy of the passed filename because
        * it might be identical to 'PCB->Filename'
        */
-      copy = MyStrdup (Filename, "SavePCB()");
-      SaveFree (PCB->Filename);
+      copy = strdup (Filename);
+      free (PCB->Filename);
       PCB->Filename = copy;
       SetChangedFlag (false);
     }
@@ -390,7 +390,7 @@ LoadPCB (char *Filename)
 
       /* clear 'changed flag' */
       SetChangedFlag (false);
-      PCB->Filename = MyStrdup (Filename, "LoadPCB()");
+      PCB->Filename = strdup (Filename);
       /* just in case a bad file saved file is loaded */
 
       units_mm = (PCB->Grid != (int) PCB->Grid) ? true : false;
@@ -1166,7 +1166,7 @@ LoadNewlibFootprintsFromDir(char *libpath, char *toppath)
   /* Get pointer to memory holding menu */
   menu = GetLibraryMenuMemory (&Library);
   /* Populate menuname and path vars */
-  menu->Name = MyStrdup (pcb_basename(subdir), "Newlib");
+  menu->Name = strdup (pcb_basename(subdir));
   menu->directory = strdup (pcb_basename(toppath));
 
   /* Now loop over files in this directory looking for files.
@@ -1204,7 +1204,7 @@ LoadNewlibFootprintsFromDir(char *libpath, char *toppath)
 	 * entry->ListEntry points to fp name itself.
 	 */
 	len = strlen(subdir) + strlen("/") + strlen(subdirentry->d_name) + 1;
-	entry->AllocatedMemory = MyCalloc (1, len, "ParseLibraryTree()");
+	entry->AllocatedMemory = calloc (1, len);
 	strcat (entry->AllocatedMemory, subdir);
 	strcat (entry->AllocatedMemory, PCB_DIR_SEPARATOR_S);
 
@@ -1257,7 +1257,7 @@ ParseLibraryTree (void)
   /* Additional loop to allow for multiple 'newlib' style library directories 
    * called out in Settings.LibraryTree
    */
-  libpaths = MyStrdup (Settings.LibraryTree, "ParseLibraryTree");
+  libpaths = strdup (Settings.LibraryTree);
   for (p = strtok (libpaths, PCB_PATH_DELIMETER); p && *p; p = strtok (NULL, PCB_PATH_DELIMETER))
     {
       /* remove trailing path delimeter */
@@ -1343,7 +1343,7 @@ ReadLibraryContents (void)
   /*  First load the M4 stuff.  The variable Settings.LibraryPath
    *  points to it.
    */
-  MYFREE (command);
+  free (command);
   command = EvaluateFilename (Settings.LibraryContentsCommand,
 			      Settings.LibraryPath, Settings.LibraryFilename,
 			      NULL);
@@ -1383,8 +1383,7 @@ ReadLibraryContents (void)
       if (!strncmp (inputline, "TYPE=", 5))
 	{
 	  menu = GetLibraryMenuMemory (&Library);
-	  menu->Name = MyStrdup (UNKNOWN (&inputline[5]),
-				 "ReadLibraryDescription()");
+	  menu->Name = strdup (UNKNOWN (&inputline[5]));
 	  menu->directory = strdup (Settings.LibraryFilename);
 	}
       else
@@ -1393,13 +1392,11 @@ ReadLibraryContents (void)
 	  if (!menu)
 	    {
 	      menu = GetLibraryMenuMemory (&Library);
-	      menu->Name = MyStrdup (UNKNOWN ((char *) NULL),
-				     "ReadLibraryDescription()");
+	      menu->Name = strdup (UNKNOWN ((char *) NULL));
 	      menu->directory = strdup (Settings.LibraryFilename);
 	    }
 	  entry = GetLibraryEntryMemory (menu);
-	  entry->AllocatedMemory = MyStrdup (inputline,
-					     "ReadLibraryDescription()");
+	  entry->AllocatedMemory = strdup (inputline);
 
 	  /* now break the line into pieces separated by colons */
 	  if ((entry->Template = strtok (entry->AllocatedMemory, ":")) !=
@@ -1411,8 +1408,7 @@ ReadLibraryContents (void)
 	  /* create the list entry */
 	  len = strlen (EMPTY (entry->Value)) +
 	    strlen (EMPTY (entry->Description)) + 4;
-	  entry->ListEntry = MyCalloc (len, sizeof (char),
-				       "ReadLibraryDescription()");
+	  entry->ListEntry = calloc (len, sizeof (char));
 	  sprintf (entry->ListEntry,
 		   "%s, %s", EMPTY (entry->Value),
 		   EMPTY (entry->Description));
@@ -1471,7 +1467,7 @@ ReadNetlist (char *filename)
   else
     {
       used_popen = 1;
-      MYFREE (command);
+      free (command);
       command = EvaluateFilename (Settings.RatCommand,
 				  Settings.RatPath, filename, NULL);
 
@@ -1526,7 +1522,7 @@ ReadNetlist (char *filename)
 	  if (kind == 0)
 	    {
 	      menu = GetLibraryMenuMemory (&PCB->NetlistLib);
-	      menu->Name = MyStrdup (temp, "ReadNetlist()");
+	      menu->Name = strdup (temp);
 	      menu->flag = 1;
 	      kind++;
 	    }
@@ -1535,12 +1531,12 @@ ReadNetlist (char *filename)
 	      if (kind == 1 && strchr (temp, '-') == NULL)
 		{
 		  kind++;
-		  menu->Style = MyStrdup (temp, "ReadNetlist()");
+		  menu->Style = strdup (temp);
 		}
 	      else
 		{
 		  entry = GetLibraryEntryMemory (menu);
-		  entry->ListEntry = MyStrdup (temp, "ReadNetlist()");
+		  entry->ListEntry = strdup (temp);
 		}
 	    }
 	}
diff --git a/src/find.c b/src/find.c
index 8d468bb..3176357 100644
--- a/src/find.c
+++ b/src/find.c
@@ -569,19 +569,26 @@ FreeLayoutLookupMemory (void)
 
   for (i = 0; i < max_copper_layer; i++)
     {
-      MYFREE (LineList[i].Data);
-      MYFREE (ArcList[i].Data);
-      MYFREE (PolygonList[i].Data);
+      free (LineList[i].Data);
+      LineList[i].Data = NULL;
+      free (ArcList[i].Data);
+      ArcList[i].Data = NULL;
+      free (PolygonList[i].Data);
+      PolygonList[i].Data = NULL;
     }
-  MYFREE (PVList.Data);
-  MYFREE (RatList.Data);
+  free (PVList.Data);
+  PVList.Data = NULL;
+  free (RatList.Data);
+  RatList.Data = NULL;
 }
 
 void
 FreeComponentLookupMemory (void)
 {
-  MYFREE (PadList[0].Data);
-  MYFREE (PadList[1].Data);
+  free (PadList[0].Data);
+  PadList[0].Data = NULL;
+  free (PadList[1].Data);
+  PadList[1].Data = NULL;
 }
 
 /* ---------------------------------------------------------------------------
@@ -608,9 +615,7 @@ InitComponentLookup (void)
   for (i = 0; i < 2; i++)
     {
       /* allocate memory for working list */
-      PadList[i].Data =
-        (void **) MyCalloc (NumberOfPads[i], sizeof (PadTypePtr),
-                            "InitComponentLookup()");
+      PadList[i].Data = calloc (NumberOfPads[i], sizeof (PadTypePtr));
 
       /* clear some struct members */
       PadList[i].Location = 0;
@@ -637,16 +642,12 @@ InitLayoutLookup (void)
       if (layer->LineN)
         {
           /* allocate memory for line pointer lists */
-          LineList[i].Data =
-            (void **) MyCalloc (layer->LineN, sizeof (LineTypePtr),
-                                "InitLayoutLookup()");
+          LineList[i].Data = calloc (layer->LineN, sizeof (LineTypePtr));
           LineList[i].Size = layer->LineN;
         }
       if (layer->ArcN)
         {
-          ArcList[i].Data =
-            (void **) MyCalloc (layer->ArcN, sizeof (ArcTypePtr),
-                                "InitLayoutLookup()");
+          ArcList[i].Data = calloc (layer->ArcN, sizeof (ArcTypePtr));
           ArcList[i].Size = layer->ArcN;
         }
 
@@ -654,9 +655,7 @@ InitLayoutLookup (void)
       /* allocate memory for polygon list */
       if (layer->PolygonN)
         {
-          PolygonList[i].Data = (void **) MyCalloc (layer->PolygonN,
-                                                    sizeof (PolygonTypePtr),
-                                                    "InitLayoutLookup()");
+          PolygonList[i].Data = calloc (layer->PolygonN, sizeof (PolygonTypePtr));
           PolygonList[i].Size = layer->PolygonN;
         }
 
@@ -681,15 +680,13 @@ InitLayoutLookup (void)
   else
     TotalV = 0;
   /* allocate memory for 'new PV to check' list and clear struct */
-  PVList.Data = (void **) MyCalloc (TotalP + TotalV, sizeof (PinTypePtr),
-                                    "InitLayoutLookup()");
+  PVList.Data = calloc (TotalP + TotalV, sizeof (PinTypePtr));
   PVList.Size = TotalP + TotalV;
   PVList.Location = 0;
   PVList.DrawLocation = 0;
   PVList.Number = 0;
   /* Initialize ratline data */
-  RatList.Data = (void **) MyCalloc (PCB->Data->RatN, sizeof (RatTypePtr),
-                                     "InitLayoutLookup()");
+  RatList.Data = calloc (PCB->Data->RatN, sizeof (RatTypePtr));
   RatList.Size = PCB->Data->RatN;
   RatList.Location = 0;
   RatList.DrawLocation = 0;
diff --git a/src/fontmode.c b/src/fontmode.c
index bd9fcee..4f7f5b8 100644
--- a/src/fontmode.c
+++ b/src/fontmode.c
@@ -94,10 +94,10 @@ FontEdit (int argc, char **argv, int Ux, int Uy)
   PCB->MaxWidth = CELL_SIZE * 18;
   PCB->MaxHeight = CELL_SIZE * ((MAX_FONTPOSITION + 15) / 16 + 2);
   PCB->Grid = 500.0;
-  PCB->Data->Layer[0].Name = MyStrdup ("Font", "FontEdit");
-  PCB->Data->Layer[1].Name = MyStrdup ("OrigFont", "FontEdit");
-  PCB->Data->Layer[2].Name = MyStrdup ("Width", "FontEdit");
-  PCB->Data->Layer[3].Name = MyStrdup ("Grid", "FontEdit");
+  PCB->Data->Layer[0].Name = strdup ("Font");
+  PCB->Data->Layer[1].Name = strdup ("OrigFont");
+  PCB->Data->Layer[2].Name = strdup ("Width");
+  PCB->Data->Layer[3].Name = strdup ("Grid");
   hid_action ("PCBChanged");
   hid_action ("LayersChanged");
 
diff --git a/src/hid/common/flags.c b/src/hid/common/flags.c
index e4a566d..30859fb 100644
--- a/src/hid/common/flags.c
+++ b/src/hid/common/flags.c
@@ -110,7 +110,7 @@ hid_get_flag (const char *name)
       if (nbuf < (cp - name + 1))
 	{
 	  nbuf = cp - name + 10;
-	  buf = MyRealloc (buf, nbuf, "hid_get_flag");
+	  buf = realloc (buf, nbuf);
 	}
       memcpy (buf, name, cp - name);
       buf[cp - name] = 0;
diff --git a/src/hid/gerber/gerber.c b/src/hid/gerber/gerber.c
index e2d9c57..8b3658c 100644
--- a/src/hid/gerber/gerber.c
+++ b/src/hid/gerber/gerber.c
@@ -229,9 +229,7 @@ SetAppLayer (int l)
     {
       int prev = n_layerapps;
       n_layerapps = l + 1;
-      layerapps =
-	MyRealloc (layerapps, n_layerapps * sizeof (Apertures),
-		   "SetAppLayer");
+      layerapps = realloc (layerapps, n_layerapps * sizeof (Apertures));
       curapp = layerapps + prev;
       while (curapp < layerapps + n_layerapps)
 	{
@@ -363,7 +361,7 @@ gerber_do_export (HID_Attr_Val * options)
   all_layers = options[HA_all_layers].int_value;
 
   i = strlen (fnbase);
-  filename = MyRealloc (filename, i + 40, "gerber");
+  filename = realloc (filename, i + 40);
   strcpy (filename, fnbase);
   strcat (filename, ".");
   filesuff = filename + strlen (filename);
diff --git a/src/hid/gtk/gtkhid-gdk.c b/src/hid/gtk/gtkhid-gdk.c
index 461b779..5cd969c 100644
--- a/src/hid/gtk/gtkhid-gdk.c
+++ b/src/hid/gtk/gtkhid-gdk.c
@@ -133,8 +133,7 @@ ghid_draw_grid (void)
   if (n > npoints)
     {
       npoints = n + 10;
-      points =
-	MyRealloc (points, npoints * sizeof (GdkPoint), "gtk_draw_grid");
+      points = realloc (points, npoints * sizeof (GdkPoint));
     }
   n = 0;
   for (x = x1; x <= x2; x += PCB->Grid)
@@ -601,8 +600,7 @@ ghid_fill_polygon (hidGC gc, int n_coords, int *x, int *y)
   if (npoints < n_coords)
     {
       npoints = n_coords + 1;
-      points = MyRealloc (points,
-			  npoints * sizeof (GdkPoint), (char *) __FUNCTION__);
+      points = realloc (points, npoints * sizeof (GdkPoint));
     }
   for (i = 0; i < n_coords; i++)
     {
diff --git a/src/hid/gtk/gui-dialog-size.c b/src/hid/gtk/gui-dialog-size.c
index 2f49f06..16caff3 100644
--- a/src/hid/gtk/gui-dialog-size.c
+++ b/src/hid/gtk/gui-dialog-size.c
@@ -308,7 +308,7 @@ ghid_route_style_dialog (gint index, RouteStyleType * temp_rst)
       if (index < NUM_STYLES && !set_temp1 && !set_temp2)
 	{
 	  string = ghid_entry_get_text (sd->name_entry);
-	  SaveFree (rst->Name);
+	  free (rst->Name);
 	  rst->Name = StripWhiteSpaceAndDup (string);
 	  pcb_use_route_style (rst);
 	  SetChangedFlag (true);
diff --git a/src/hid/gtk/gui-top-window.c b/src/hid/gtk/gui-top-window.c
index 9c30a93..90977e2 100644
--- a/src/hid/gtk/gui-top-window.c
+++ b/src/hid/gtk/gui-top-window.c
@@ -303,9 +303,7 @@ note_toggle_flag (const char *actionname, MenuFlagType type, char *name)
   if (n_tflags >= max_tflags)
     {
       max_tflags += 20;
-      tflags =
-	MyRealloc (tflags, max_tflags * sizeof (ToggleFlagType),
-		   __FUNCTION__);
+      tflags = realloc (tflags, max_tflags * sizeof (ToggleFlagType));
     }
   tflags[n_tflags].actionname = strdup (actionname);
   tflags[n_tflags].flagname = name;
diff --git a/src/hid/lesstif/main.c b/src/hid/lesstif/main.c
index 5caec02..c4a70a9 100644
--- a/src/hid/lesstif/main.c
+++ b/src/hid/lesstif/main.c
@@ -2236,8 +2236,7 @@ draw_grid ()
   if (n > npoints)
     {
       npoints = n + 10;
-      points =
-	MyRealloc (points, npoints * sizeof (XPoint), "lesstif_draw_grid");
+      points = realloc (points, npoints * sizeof (XPoint));
     }
   n = 0;
   prevx = 0;
@@ -3675,7 +3674,7 @@ lesstif_show_item (void *item)
   if (!mainwind)
     return;
 
-  pd = (PinoutData *) MyCalloc (1, sizeof (PinoutData), "lesstif_show_item");
+  pd = calloc (1, sizeof (PinoutData));
 
   pd->item = item;
 
diff --git a/src/hid/lesstif/menu.c b/src/hid/lesstif/menu.c
index 9983d42..75acd1e 100644
--- a/src/hid/lesstif/menu.c
+++ b/src/hid/lesstif/menu.c
@@ -672,9 +672,7 @@ note_widget_flag (Widget w, char *type, char *name)
   if (n_wflags >= max_wflags)
     {
       max_wflags += 20;
-      wflags =
-	MyRealloc (wflags, max_wflags * sizeof (WidgetFlagType),
-		   __FUNCTION__);
+      wflags = realloc (wflags, max_wflags * sizeof (WidgetFlagType));
     }
   wflags[n_wflags].w = w;
   wflags[n_wflags].flagname = name;
diff --git a/src/hid/lesstif/styles.c b/src/hid/lesstif/styles.c
index fb9d3b3..8db2d73 100644
--- a/src/hid/lesstif/styles.c
+++ b/src/hid/lesstif/styles.c
@@ -452,8 +452,7 @@ lesstif_insert_style_buttons (Widget menu)
 
   num_style_buttons++;
   s = num_style_buttons * sizeof (StyleButtons);
-  style_button_list =
-    (StyleButtons *) MyRealloc (style_button_list, s, __FUNCTION__);
+  style_button_list = realloc (style_button_list, s);
   sb = style_button_list + num_style_buttons - 1;
 
   for (i = 0; i < NUM_STYLES; i++)
diff --git a/src/intersect.c b/src/intersect.c
index 8f99ad7..7389ba9 100644
--- a/src/intersect.c
+++ b/src/intersect.c
@@ -97,8 +97,7 @@ createSortedYList (BoxListTypePtr boxlist)
   int i, n;
   /* create sorted list of Y coordinates */
   yCoords.size = 2 * boxlist->BoxN;
-  yCoords.p = MyCalloc (yCoords.size, sizeof (*yCoords.p),
-                        "createSortedYList");
+  yCoords.p = calloc (yCoords.size, sizeof (*yCoords.p));
   for (i = 0; i < boxlist->BoxN; i++)
     {
       yCoords.p[2 * i] = boxlist->Box[i].Y1;
@@ -124,7 +123,7 @@ createSegmentTree (LocationType * yCoords, int N)
   int i;
   /* size is twice the nearest larger power of 2 */
   st.size = 2 * nextpwrof2 (N);
-  st.nodes = MyCalloc (st.size, sizeof (*st.nodes), "createSegmentTree");
+  st.nodes = calloc (st.size, sizeof (*st.nodes));
   /* initialize the rightmost leaf node */
   st.nodes[st.size - 1].left = (N > 0) ? yCoords[--N] : 10;
   st.nodes[st.size - 1].right = st.nodes[st.size - 1].left + 1;
@@ -235,10 +234,8 @@ ComputeUnionArea (BoxListTypePtr boxlist)
   segtree = createSegmentTree (yCoords.p, yCoords.size);
   free (yCoords.p);
   /* create sorted list of left and right X coordinates of rectangles */
-  rectLeft = MyCalloc (boxlist->BoxN, sizeof (*rectLeft),
-                       "ComputeUnionArea(1)");
-  rectRight = MyCalloc (boxlist->BoxN, sizeof (*rectRight),
-                        "ComputeUnionArea(2)");
+  rectLeft = calloc (boxlist->BoxN, sizeof (*rectLeft));
+  rectRight = calloc (boxlist->BoxN, sizeof (*rectRight));
   for (i = 0; i < boxlist->BoxN; i++)
     {
       assert (boxlist->Box[i].X1 <= boxlist->Box[i].X2);
diff --git a/src/main.c b/src/main.c
index ba8c959..190fb5a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -224,7 +224,7 @@ usage_hid (HID * h)
       exporter = NULL;
     }
 
-  note = (UsageNotes *) MyMalloc (sizeof (UsageNotes), "usage_hid");
+  note = malloc (sizeof (UsageNotes));
   note->next = usage_notes;
   note->seen = attributes;
   usage_notes = note;
@@ -957,7 +957,7 @@ main (int argc, char *argv[])
     {
       char buf[20];
       sprintf (buf, "signal%d", i + 1);
-      Settings.DefaultLayerName[i] = MyStrdup (buf, "DefaultLayerNames");
+      Settings.DefaultLayerName[i] = strdup (buf);
       Settings.LayerColor[i] = "#c49350";
       Settings.LayerSelectedColor[i] = "#00ffff";
     }
@@ -1018,7 +1018,7 @@ main (int argc, char *argv[])
        * file might not exist
        */
       if (LoadPCB (command_line_pcb))
-	PCB->Filename = MyStrdup (command_line_pcb, "main()");
+	PCB->Filename = strdup (command_line_pcb);
     }
 
   if (Settings.InitialLayerStack
diff --git a/src/misc.c b/src/misc.c
index 76b05c0..79d9e90 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -723,7 +723,7 @@ ParseRouteString (char *s, RouteStyleTypePtr routeStyle, int scale)
       for (i = 0; *s && *s != ','; i++)
         Name[i] = *s++;
       Name[i] = '\0';
-      routeStyle->Name = MyStrdup (Name, "ParseRouteString()");
+      routeStyle->Name = strdup (Name);
       if (!isdigit ((int) *++s))
         goto error;
       GetNum (&s, &routeStyle->Thick);
@@ -943,7 +943,7 @@ EvaluateFilename (char *Template, char *Path, char *Filename, char *Parameter)
   if (Settings.verbose)
     printf ("EvaluateFilename: \033[32m%s\033[0m\n", command.Data);
 
-  return (MyStrdup (command.Data, "EvaluateFilename()"));
+  return strdup (command.Data);
 }
 
 /* ---------------------------------------------------------------------------
@@ -962,13 +962,13 @@ ExpandFilename (char *Dirname, char *Filename)
   DSClearString (&answer);
   if (Dirname)
     {
-      command = MyCalloc (strlen (Filename) + strlen (Dirname) + 7,
-                          sizeof (char), "ExpandFilename()");
+      command = calloc (strlen (Filename) + strlen (Dirname) + 7,
+                        sizeof (char));
       sprintf (command, "echo %s/%s", Dirname, Filename);
     }
   else
     {
-      command = MyCalloc (strlen (Filename) + 6, sizeof (char), "Expand()");
+      command = calloc (strlen (Filename) + 6, sizeof (char));
       sprintf (command, "echo %s", Filename);
     }
 
@@ -984,13 +984,13 @@ ExpandFilename (char *Dirname, char *Filename)
             DSAddCharacter (&answer, c);
         }
 
-      SaveFree (command);
+      free (command);
       return (pclose (pipe) ? NULL : answer.Data);
     }
 
   /* couldn't be expanded by the shell */
   PopenErrorMessage (command);
-  SaveFree (command);
+  free (command);
   return (NULL);
 }
 
@@ -1904,7 +1904,7 @@ AttributePutToList (AttributeListType *list, char *name, char *value, int replac
 	if (strcmp (name, list->List[i].name) == 0)
 	  {
 	    free (list->List[i].value);
-	    list->List[i].value = MyStrdup (value, "AttributePutToList");
+	    list->List[i].value = strdup (value);
 	    return 1;
 	  }
     }
@@ -1920,8 +1920,8 @@ AttributePutToList (AttributeListType *list, char *name, char *value, int replac
 
   /* Now add the new attribute.  */
   i = list->Number;
-  list->List[i].name = MyStrdup (name, "AttributePutToList");
-  list->List[i].value = MyStrdup (value, "AttributePutToList");
+  list->List[i].name = strdup (name);
+  list->List[i].value = strdup (value);
   list->Number ++;
   return 0;
 }
diff --git a/src/move.c b/src/move.c
index cce6e19..cbb2e3d 100644
--- a/src/move.c
+++ b/src/move.c
@@ -970,7 +970,7 @@ MoveLayer (int old_index, int new_index)
       max_copper_layer++;
       memset (lp, 0, sizeof (LayerType));
       lp->On = 1;
-      lp->Name = MyStrdup ("New Layer", "MoveLayer");
+      lp->Name = strdup ("New Layer");
       lp->Color = Settings.LayerColor[new_index];
       lp->SelectedColor = Settings.LayerSelectedColor[new_index];
       for (l = 0; l < max_copper_layer; l++)
diff --git a/src/mymem.c b/src/mymem.c
index 59f8f8d..09cb6ab 100644
--- a/src/mymem.c
+++ b/src/mymem.c
@@ -69,9 +69,8 @@ GetRubberbandMemory (void)
       Crosshair.AttachedObject.RubberbandMax)
     {
       Crosshair.AttachedObject.RubberbandMax += STEP_RUBBERBAND;
-      ptr = MyRealloc (ptr,
-		       Crosshair.AttachedObject.RubberbandMax *
-		       sizeof (RubberbandType), "GetRubberbandMemory()");
+      ptr = realloc (ptr, Crosshair.AttachedObject.RubberbandMax *
+                          sizeof (RubberbandType));
       Crosshair.AttachedObject.Rubberband = ptr;
       memset (ptr + Crosshair.AttachedObject.RubberbandN, 0,
 	      STEP_RUBBERBAND * sizeof (RubberbandType));
@@ -88,8 +87,7 @@ GetPointerMemory (PointerListTypePtr list)
   if (list->PtrN >= list->PtrMax)
     {
       list->PtrMax = STEP_POINT + (2 * list->PtrMax);
-      ptr = MyRealloc (ptr, list->PtrMax * sizeof (void *),
-		       "GetPointerMemory()");
+      ptr = realloc (ptr, list->PtrMax * sizeof (void *));
       list->Ptr = ptr;
       memset (ptr + list->PtrN, 0,
 	      (list->PtrMax - list->PtrN) * sizeof (void *));
@@ -100,7 +98,7 @@ GetPointerMemory (PointerListTypePtr list)
 void
 FreePointerListMemory (PointerListTypePtr list)
 {
-  MYFREE (list->Ptr);
+  free (list->Ptr);
   memset (list, 0, sizeof (PointerListType));
 }
 
@@ -116,8 +114,7 @@ GetBoxMemory (BoxListTypePtr Boxes)
   if (Boxes->BoxN >= Boxes->BoxMax)
     {
       Boxes->BoxMax = STEP_POINT + (2 * Boxes->BoxMax);
-      box = MyRealloc (box, Boxes->BoxMax * sizeof (BoxType),
-		       "GetBoxMemory()");
+      box = realloc (box, Boxes->BoxMax * sizeof (BoxType));
       Boxes->Box = box;
       memset (box + Boxes->BoxN, 0,
 	      (Boxes->BoxMax - Boxes->BoxN) * sizeof (BoxType));
@@ -138,8 +135,7 @@ GetConnectionMemory (NetTypePtr Net)
   if (Net->ConnectionN >= Net->ConnectionMax)
     {
       Net->ConnectionMax += STEP_POINT;
-      con = MyRealloc (con, Net->ConnectionMax * sizeof (ConnectionType),
-		       "GetConnectionMemory()");
+      con = realloc (con, Net->ConnectionMax * sizeof (ConnectionType));
       Net->Connection = con;
       memset (con + Net->ConnectionN, 0,
 	      STEP_POINT * sizeof (ConnectionType));
@@ -159,8 +155,7 @@ GetNetMemory (NetListTypePtr Netlist)
   if (Netlist->NetN >= Netlist->NetMax)
     {
       Netlist->NetMax += STEP_POINT;
-      net = MyRealloc (net, Netlist->NetMax * sizeof (NetType),
-		       "GetNetMemory()");
+      net = realloc (net, Netlist->NetMax * sizeof (NetType));
       Netlist->Net = net;
       memset (net + Netlist->NetN, 0, STEP_POINT * sizeof (NetType));
     }
@@ -179,9 +174,8 @@ GetNetListMemory (NetListListTypePtr Netlistlist)
   if (Netlistlist->NetListN >= Netlistlist->NetListMax)
     {
       Netlistlist->NetListMax += STEP_POINT;
-      netlist = MyRealloc
-	(netlist, Netlistlist->NetListMax * sizeof (NetListType),
-	 "GetNetListMemory()");
+      netlist = realloc (netlist,
+                         Netlistlist->NetListMax * sizeof (NetListType));
       Netlistlist->NetList = netlist;
       memset (netlist + Netlistlist->NetListN, 0,
 	      STEP_POINT * sizeof (NetListType));
@@ -211,8 +205,7 @@ GetPinMemory (ElementTypePtr Element)
 	  END_LOOP;
 	}
       Element->PinMax += STEP_PIN;
-      pin = MyRealloc (pin, Element->PinMax * sizeof (PinType),
-		       "GetPinMemory()");
+      pin = realloc (pin, Element->PinMax * sizeof (PinType));
       Element->Pin = pin;
       memset (pin + Element->PinN, 0, STEP_PIN * sizeof (PinType));
       if (onBoard)
@@ -249,8 +242,7 @@ GetPadMemory (ElementTypePtr Element)
 	  END_LOOP;
 	}
       Element->PadMax += STEP_PAD;
-      pad = MyRealloc (pad, Element->PadMax * sizeof (PadType),
-		       "GetPadMemory()");
+      pad = realloc (pad, Element->PadMax * sizeof (PadType));
       Element->Pad = pad;
       memset (pad + Element->PadN, 0, STEP_PAD * sizeof (PadType));
       if (onBoard)
@@ -279,8 +271,7 @@ GetViaMemory (DataTypePtr Data)
       Data->ViaMax += STEP_VIA;
       if (Data->via_tree)
 	r_destroy_tree (&Data->via_tree);
-      via = MyRealloc (via, Data->ViaMax * sizeof (PinType),
-		       "GetViaMemory()");
+      via = realloc (via, Data->ViaMax * sizeof (PinType));
       Data->Via = via;
       memset (via + Data->ViaN, 0, STEP_VIA * sizeof (PinType));
       Data->via_tree = r_create_tree (NULL, 0, 0);
@@ -308,8 +299,7 @@ GetRatMemory (DataTypePtr Data)
       /* all of the pointers move, so rebuild the whole tree */
       if (Data->rat_tree)
         r_destroy_tree (&Data->rat_tree);
-      rat = MyRealloc (rat, Data->RatMax * sizeof (RatType),
-		       "GetRatMemory()");
+      rat = realloc (rat, Data->RatMax * sizeof (RatType));
       Data->Rat = rat;
       memset (rat + Data->RatN, 0, STEP_RAT * sizeof (RatType));
       Data->rat_tree = r_create_tree (NULL, 0, 0);
@@ -337,8 +327,7 @@ GetLineMemory (LayerTypePtr Layer)
       /* all of the pointers move, so rebuild the whole tree */
       if (Layer->line_tree)
 	r_destroy_tree (&Layer->line_tree);
-      line = MyRealloc (line, Layer->LineMax * sizeof (LineType),
-			"GetLineMemory()");
+      line = realloc (line, Layer->LineMax * sizeof (LineType));
       Layer->Line = line;
       memset (line + Layer->LineN, 0, STEP_LINE * sizeof (LineType));
       Layer->line_tree = r_create_tree (NULL, 0, 0);
@@ -365,8 +354,7 @@ GetArcMemory (LayerTypePtr Layer)
       Layer->ArcMax += STEP_ARC;
       if (Layer->arc_tree)
 	r_destroy_tree (&Layer->arc_tree);
-      arc = MyRealloc (arc, Layer->ArcMax * sizeof (ArcType),
-		       "GetArcMemory()");
+      arc = realloc (arc, Layer->ArcMax * sizeof (ArcType));
       Layer->Arc = arc;
       memset (arc + Layer->ArcN, 0, STEP_ARC * sizeof (ArcType));
       Layer->arc_tree = r_create_tree (NULL, 0, 0);
@@ -393,8 +381,7 @@ GetTextMemory (LayerTypePtr Layer)
       Layer->TextMax += STEP_TEXT;
       if (Layer->text_tree)
 	r_destroy_tree (&Layer->text_tree);
-      text = MyRealloc (text, Layer->TextMax * sizeof (TextType),
-			"GetTextMemory()");
+      text = realloc (text, Layer->TextMax * sizeof (TextType));
       Layer->Text = text;
       memset (text + Layer->TextN, 0, STEP_TEXT * sizeof (TextType));
       Layer->text_tree = r_create_tree (NULL, 0, 0);
@@ -421,8 +408,7 @@ GetPolygonMemory (LayerTypePtr Layer)
       Layer->PolygonMax += STEP_POLYGON;
       if (Layer->polygon_tree)
 	r_destroy_tree (&Layer->polygon_tree);
-      polygon = MyRealloc (polygon, Layer->PolygonMax * sizeof (PolygonType),
-			   "GetPolygonMemory()");
+      polygon = realloc (polygon, Layer->PolygonMax * sizeof (PolygonType));
       Layer->Polygon = polygon;
       memset (polygon + Layer->PolygonN, 0,
 	      STEP_POLYGON * sizeof (PolygonType));
@@ -449,8 +435,7 @@ GetPointMemoryInPolygon (PolygonTypePtr Polygon)
   if (Polygon->PointN >= Polygon->PointMax)
     {
       Polygon->PointMax += STEP_POLYGONPOINT;
-      points = MyRealloc (points, Polygon->PointMax * sizeof (PointType),
-			  "GetPointMemoryInPolygon()");
+      points = realloc (points, Polygon->PointMax * sizeof (PointType));
       Polygon->Points = points;
       memset (points + Polygon->PointN, 0,
 	      STEP_POLYGONPOINT * sizeof (PointType));
@@ -471,8 +456,7 @@ GetHoleIndexMemoryInPolygon (PolygonTypePtr Polygon)
   if (Polygon->HoleIndexN >= Polygon->HoleIndexMax)
     {
       Polygon->HoleIndexMax += STEP_POLYGONHOLEINDEX;
-      holeindex = MyRealloc (holeindex, Polygon->HoleIndexMax * sizeof (int),
-			     "GetHoleIndexMemoryInPolygon()");
+      holeindex = realloc (holeindex, Polygon->HoleIndexMax * sizeof (int));
       Polygon->HoleIndex = holeindex;
       memset (holeindex + Polygon->HoleIndexN, 0,
 	      STEP_POLYGONHOLEINDEX * sizeof (int));
@@ -495,8 +479,7 @@ GetElementMemory (DataTypePtr Data)
       Data->ElementMax += STEP_ELEMENT;
       if (Data->element_tree)
 	r_destroy_tree (&Data->element_tree);
-      element = MyRealloc (element, Data->ElementMax * sizeof (ElementType),
-			   "GetElementMemory()");
+      element = realloc (element, Data->ElementMax * sizeof (ElementType));
       Data->Element = element;
       memset (element + Data->ElementN, 0,
 	      STEP_ELEMENT * sizeof (ElementType));
@@ -545,8 +528,7 @@ GetLibraryMenuMemory (LibraryTypePtr lib)
   if (lib->MenuN >= lib->MenuMax)
     {
       lib->MenuMax += STEP_LIBRARYMENU;
-      menu = MyRealloc (menu, lib->MenuMax * sizeof (LibraryMenuType),
-			"GetLibraryMenuMemory()");
+      menu = realloc (menu, lib->MenuMax * sizeof (LibraryMenuType));
       lib->Menu = menu;
       memset (menu + lib->MenuN, 0,
 	      STEP_LIBRARYMENU * sizeof (LibraryMenuType));
@@ -566,8 +548,7 @@ GetLibraryEntryMemory (LibraryMenuTypePtr Menu)
   if (Menu->EntryN >= Menu->EntryMax)
     {
       Menu->EntryMax += STEP_LIBRARYENTRY;
-      entry = MyRealloc (entry, Menu->EntryMax * sizeof (LibraryEntryType),
-			 "GetLibraryEntryMemory()");
+      entry = realloc (entry, Menu->EntryMax * sizeof (LibraryEntryType));
       Menu->Entry = entry;
       memset (entry + Menu->EntryN, 0,
 	      STEP_LIBRARYENTRY * sizeof (LibraryEntryType));
@@ -589,9 +570,8 @@ GetDrillElementMemory (DrillTypePtr Drill)
   if (Drill->ElementN >= Drill->ElementMax)
     {
       Drill->ElementMax += STEP_ELEMENT;
-      element =
-	MyRealloc (element, Drill->ElementMax * sizeof (ElementTypeHandle),
-		   "GetDrillElementMemory()");
+      element = realloc (element,
+                         Drill->ElementMax * sizeof (ElementTypeHandle));
       Drill->Element = element;
       memset (element + Drill->ElementN, 0,
 	      STEP_ELEMENT * sizeof (ElementTypeHandle));
@@ -613,8 +593,7 @@ GetDrillPinMemory (DrillTypePtr Drill)
   if (Drill->PinN >= Drill->PinMax)
     {
       Drill->PinMax += STEP_POINT;
-      pin = MyRealloc (pin, Drill->PinMax * sizeof (PinTypeHandle),
-		       "GetDrillPinMemory()");
+      pin = realloc (pin, Drill->PinMax * sizeof (PinTypeHandle));
       Drill->Pin = pin;
       memset (pin + Drill->PinN, 0, STEP_POINT * sizeof (PinTypeHandle));
     }
@@ -633,8 +612,7 @@ GetDrillInfoDrillMemory (DrillInfoTypePtr DrillInfo)
   if (DrillInfo->DrillN >= DrillInfo->DrillMax)
     {
       DrillInfo->DrillMax += STEP_DRILL;
-      drill = MyRealloc (drill, DrillInfo->DrillMax * sizeof (DrillType),
-			 "GetDrillInfoDrillMemory()");
+      drill = realloc (drill, DrillInfo->DrillMax * sizeof (DrillType));
       DrillInfo->Drill = drill;
       memset (drill + DrillInfo->DrillN, 0, STEP_DRILL * sizeof (DrillType));
     }
@@ -642,112 +620,6 @@ GetDrillInfoDrillMemory (DrillInfoTypePtr DrillInfo)
 }
 
 /* ---------------------------------------------------------------------------
- * allocates memory with error handling
- */
-void *
-MyCalloc (size_t Number, size_t Size, const char *Text)
-{
-  void *p;
-
-#ifdef MEM_DEBUG
-  fprintf (stderr, "MyCalloc %d by %d from %s ", Number, Size, Text);
-#endif
-  /* InitComponentLookup() at least can ask for zero here, so return something
-     |  that can be freed.
-   */
-  if (Number == 0)
-    Number = 1;
-  if (Size == 0)
-    Size = 1;
-
-  if ((p = calloc (Number, Size)) == NULL)
-    MyFatal ("out of memory during malloc() in '%s'()\n",
-	     (Text ? Text : "(unknown)"));
-#ifdef MEM_DEBUG
-  fprintf (stderr, "returned 0x%x\n", p);
-#endif
-  return (p);
-}
-
-void *
-MyMalloc (size_t Size, const char *Text)
-{
-  void *p;
-
-#ifdef MEM_DEBUG
-  fprintf (stderr, "MyMalloc %d by %d from %s ", Number, Size, Text);
-#endif
-  /* avoid malloc of 0 bytes */
-  if (Size == 0)
-    Size = 1;
-  if ((p = malloc (Size)) == NULL)
-    MyFatal ("out of memory during malloc() in '%s'()\n",
-	     (Text ? Text : "(unknown)"));
-#ifdef MEM_DEBUG
-  fprintf (stderr, "returned 0x%x\n", p);
-#endif
-  return (p);
-}
-
-/* ---------------------------------------------------------------------------
- * allocates memory with error handling
- * this is a save version because BSD doesn't support the
- * handling of NULL pointers in realloc()
- */
-void *
-MyRealloc (void *Ptr, size_t Size, const char *Text)
-{
-  void *p;
-
-#ifdef MEM_DEBUG
-  fprintf (stderr, "0x%x Realloc to %d from %s ", Ptr, Size, Text);
-#endif
-  if (Size == 0)
-    Size = 1;
-  p = Ptr ? realloc (Ptr, Size) : malloc (Size);
-  if (!p)
-    MyFatal ("out of memory during realloc() in '%s'()\n",
-	     (Text ? Text : "(unknown)"));
-#ifdef MEM_DEBUG
-  fprintf (stderr, "returned 0x%x\n", p);
-#endif
-  return (p);
-}
-
-/* ---------------------------------------------------------------------------
- * allocates memory for a new string, does some error processing
- */
-char *
-MyStrdup (char *S, const char *Text)
-{
-  char *p = NULL;
-
-  /* bug-fix by Ulrich Pegelow (ulrpeg@xxxxxxxxxxxxxx) */
-  if (S && ((p = strdup (S)) == NULL))
-    MyFatal ("out of memory during g_strdup() in '%s'\n",
-	     (Text ? Text : "(unknown)"));
-#ifdef MEM_DEBUG
-  fprintf (stderr, "g_strdup returning 0x%x\n", p);
-#endif
-  return (p);
-}
-
-/* ---------------------------------------------------------------------------
- * frees memory and sets pointer to NULL
- * too troublesome for modern C compiler,
- * warning: dereferencing type-punned pointer will break strict-aliasing rules
- * Use MYFREE() macro instead
- */
-#if 0
-void
-MyFree (char **Ptr)
-{
-  SaveFree (*Ptr);
-  *Ptr = NULL;
-}
-#endif
-
-/* ---------------------------------------------------------------------------
  * frees memory used by a polygon
  */
 void
@@ -755,8 +627,8 @@ FreePolygonMemory (PolygonTypePtr Polygon)
 {
   if (Polygon)
     {
-      MYFREE (Polygon->Points);
-      MYFREE (Polygon->HoleIndex);
+      free (Polygon->Points);
+      free (Polygon->HoleIndex);
       if (Polygon->Clipped)
 	poly_Free (&Polygon->Clipped);
       poly_FreeContours (&Polygon->NoHoles);
@@ -772,7 +644,7 @@ FreeBoxListMemory (BoxListTypePtr Boxlist)
 {
   if (Boxlist)
     {
-      MYFREE (Boxlist->Box);
+      free (Boxlist->Box);
       memset (Boxlist, 0, sizeof (BoxListType));
     }
 }
@@ -790,7 +662,7 @@ FreeNetListMemory (NetListTypePtr Netlist)
 	FreeNetMemory (net);
       }
       END_LOOP;
-      MYFREE (Netlist->Net);
+      free (Netlist->Net);
       memset (Netlist, 0, sizeof (NetListType));
     }
 }
@@ -808,7 +680,7 @@ FreeNetListListMemory (NetListListTypePtr Netlistlist)
 	FreeNetListMemory (netlist);
       }
       END_LOOP;
-      MYFREE (Netlistlist->NetList);
+      free (Netlistlist->NetList);
       memset (Netlistlist, 0, sizeof (NetListListType));
     }
 }
@@ -821,7 +693,7 @@ FreeNetMemory (NetTypePtr Net)
 {
   if (Net)
     {
-      MYFREE (Net->Connection);
+      free (Net->Connection);
       memset (Net, 0, sizeof (NetType));
     }
 }
@@ -835,10 +707,10 @@ FreeAttributeListMemory (AttributeListTypePtr list)
 
   for (i = 0; i < list->Number; i++)
     {
-      SaveFree (list->List[i].name);
-      SaveFree (list->List[i].value);
+      free (list->List[i].name);
+      free (list->List[i].value);
     }
-  SaveFree (list->List);
+  free (list->List);
   list->List = NULL;
   list->Max = 0;
 }
@@ -853,25 +725,25 @@ FreeElementMemory (ElementTypePtr Element)
     {
       ELEMENTNAME_LOOP (Element);
       {
-	MYFREE (textstring);
+	free (textstring);
       }
       END_LOOP;
       PIN_LOOP (Element);
       {
-	MYFREE (pin->Name);
-	MYFREE (pin->Number);
+	free (pin->Name);
+	free (pin->Number);
       }
       END_LOOP;
       PAD_LOOP (Element);
       {
-	MYFREE (pad->Name);
-	MYFREE (pad->Number);
+	free (pad->Name);
+	free (pad->Number);
       }
       END_LOOP;
-      MYFREE (Element->Pin);
-      MYFREE (Element->Pad);
-      MYFREE (Element->Line);
-      MYFREE (Element->Arc);
+      free (Element->Pin);
+      free (Element->Pad);
+      free (Element->Line);
+      free (Element->Arc);
       FreeAttributeListMemory (&Element->Attributes);
       memset (Element, 0, sizeof (ElementType));
     }
@@ -887,15 +759,15 @@ FreePCBMemory (PCBTypePtr PCBPtr)
 
   if (PCBPtr)
     {
-      MYFREE (PCBPtr->Name);
-      MYFREE (PCBPtr->Filename);
-      MYFREE (PCBPtr->PrintFilename);
+      free (PCBPtr->Name);
+      free (PCBPtr->Filename);
+      free (PCBPtr->PrintFilename);
       if (PCBPtr->Data)
 	FreeDataMemory (PCBPtr->Data);
-      MYFREE (PCBPtr->Data);
+      free (PCBPtr->Data);
       /* release font symbols */
       for (i = 0; i <= MAX_FONTPOSITION; i++)
-	MYFREE (PCBPtr->Font.Symbol[i].Line);
+	free (PCBPtr->Font.Symbol[i].Line);
       FreeLibraryMemory (&PCBPtr->NetlistLib);
       FreeAttributeListMemory (&PCBPtr->Attributes);
       /* clear struct */
@@ -920,43 +792,43 @@ FreeDataMemory (DataTypePtr Data)
     {
       VIA_LOOP (Data);
       {
-	MYFREE (via->Name);
+	free (via->Name);
       }
       END_LOOP;
-      MYFREE (Data->Via);
+      free (Data->Via);
       ELEMENT_LOOP (Data);
       {
 	FreeElementMemory (element);
       }
       END_LOOP;
-      MYFREE (Data->Element);
-      MYFREE (Data->Rat);
+      free (Data->Element);
+      free (Data->Rat);
 
       for (layer = Data->Layer, i = 0; i < MAX_LAYER + 2; layer++, i++)
 	{
 	  FreeAttributeListMemory (&layer->Attributes);
 	  TEXT_LOOP (layer);
 	  {
-	    MYFREE (text->TextString);
+	    free (text->TextString);
 	  }
 	  END_LOOP;
 	  if (layer->Name)
-	    MYFREE (layer->Name);
+	    free (layer->Name);
 	  LINE_LOOP (layer);
 	  {
 	    if (line->Number)
-	      MYFREE (line->Number);
+	      free (line->Number);
 	  }
 	  END_LOOP;
-	  MYFREE (layer->Line);
-	  MYFREE (layer->Arc);
-	  MYFREE (layer->Text);
+	  free (layer->Line);
+	  free (layer->Arc);
+	  free (layer->Text);
 	  POLYGON_LOOP (layer);
 	  {
 	    FreePolygonMemory (polygon);
 	  }
 	  END_LOOP;
-	  MYFREE (layer->Polygon);
+	  free (layer->Polygon);
 	  if (layer->line_tree)
 	    r_destroy_tree (&layer->line_tree);
 	  if (layer->arc_tree)
@@ -999,36 +871,21 @@ FreeLibraryMemory (LibraryTypePtr lib)
   {
     ENTRY_LOOP (menu);
     {
-      SaveFree ((void *) entry->AllocatedMemory);
-      SaveFree ((void *) entry->ListEntry);
+      free (entry->AllocatedMemory);
+      free (entry->ListEntry);
     }
     END_LOOP;
-    SaveFree ((void *) menu->Entry);
-    SaveFree ((void *) menu->Name);
+    free (menu->Entry);
+    free (menu->Name);
   }
   END_LOOP;
-  SaveFree ((void *) lib->Menu);
+  free (lib->Menu);
 
   /* clear struct */
   memset (lib, 0, sizeof (LibraryType));
 }
 
 /* ---------------------------------------------------------------------------
- * a 'save' free routine which first does a quick check if the pointer
- * is zero. The routine isn't implemented as a macro to make additional
- * safety features easier to implement
- */
-void
-SaveFree (void *Ptr)
-{
-#ifdef MEM_DEBUG
-  fprintf (stderr, "Freeing 0x%x\n", Ptr);
-#endif
-  if (Ptr)
-    free (Ptr);
-}
-
-/* ---------------------------------------------------------------------------
  * reallocates memory for a dynamic length string if necessary
  */
 static void
@@ -1038,7 +895,7 @@ DSRealloc (DynamicStringTypePtr Ptr, size_t Length)
   if (input_null || Length >= Ptr->MaxLength)
     {
       Ptr->MaxLength = Length + 512;
-      Ptr->Data = MyRealloc (Ptr->Data, Ptr->MaxLength, "ReallocDS()");
+      Ptr->Data = realloc (Ptr->Data, Ptr->MaxLength);
       if (input_null)
 	Ptr->Data[0] = '\0';
     }
@@ -1106,7 +963,7 @@ StripWhiteSpaceAndDup (char *S)
   /* string is not empty -> allocate memory */
   if (length)
     {
-      p2 = MyRealloc (NULL, length + 1, "StripWhiteSpace()");
+      p2 = realloc (NULL, length + 1);
       strncpy (p2, p1, length);
       *(p2 + length) = '\0';
       return (p2);
diff --git a/src/mymem.h b/src/mymem.h
index 81dff7a..46926b7 100644
--- a/src/mymem.h
+++ b/src/mymem.h
@@ -95,12 +95,6 @@ ElementTypeHandle GetDrillElementMemory (DrillTypePtr);
 PinTypeHandle GetDrillPinMemory (DrillTypePtr);
 DrillTypePtr GetDrillInfoDrillMemory (DrillInfoTypePtr);
 void **GetPointerMemory (PointerListTypePtr);
-void *MyCalloc (size_t, size_t, const char *);
-void *MyMalloc (size_t, const char *);
-void *MyRealloc (void *, size_t, const char *);
-char *MyStrdup (char *s, const char *);
-/* void MyFree (void **); */
-#define MYFREE(x) do { SaveFree(x); (x)=NULL; } while (0)
 void FreePolygonMemory (PolygonTypePtr);
 void FreeElementMemory (ElementTypePtr);
 void FreePCBMemory (PCBTypePtr);
@@ -111,7 +105,6 @@ void FreeNetMemory (NetTypePtr);
 void FreeDataMemory (DataTypePtr);
 void FreeLibraryMemory (LibraryTypePtr);
 void FreePointerListMemory (PointerListTypePtr);
-void SaveFree (void *);
 void DSAddCharacter (DynamicStringTypePtr, char);
 void DSAddString (DynamicStringTypePtr, const char *);
 void DSClearString (DynamicStringTypePtr);
diff --git a/src/netlist.c b/src/netlist.c
index ade8326..6c5ca26 100644
--- a/src/netlist.c
+++ b/src/netlist.c
@@ -242,10 +242,10 @@ netlist_clear (LibraryMenuType * net, LibraryEntryType * pin)
 static void
 netlist_style (LibraryMenuType *net, const char *style)
 {
-  if (net->Style)
-    MYFREE (net->Style);
+  free (net->Style);
+  net->Style = NULL;
   if (style)
-    net->Style = MyStrdup ((char *)style, "Netlist(Style)");
+    net->Style = strdup ((char *)style);
 }
 
 /* The primary purpose of this action is to rebuild a netlist from a
diff --git a/src/parse_l.l b/src/parse_l.l
index b1b67a8..cf246c9 100644
--- a/src/parse_l.l
+++ b/src/parse_l.l
@@ -169,7 +169,7 @@ Attribute	{ return(T_ATTRIBUTE); }
 							 * leading and trailing '"'
 							 */
 						yyleng -= 2;
-						yylval.string = MyCalloc(yyleng+1, sizeof(char), "LEX");
+						yylval.string = calloc (yyleng+1, sizeof (char));
 						p1 = (char *) (yytext +1);
 						p2 = yylval.string;
 						while(yyleng--)
@@ -245,8 +245,7 @@ static int Parse(char *Executable, char *Path, char *Filename, char *Parameter)
 	  {
 	    used_popen = 1;
 	    /* release old command and create new from template */
-	    if (command)
-	      MYFREE (command);
+	    free (command);
 	    command = EvaluateFilename(Executable, Path, Filename, Parameter);
 
 	    /* open pipe to stdout of command */
diff --git a/src/parse_y.y b/src/parse_y.y
index f4fc367..7aa7b80 100644
--- a/src/parse_y.y
+++ b/src/parse_y.y
@@ -733,7 +733,7 @@ via_hi_format
 		: T_VIA '[' NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER STRING flags ']'
 			{
 				CreateNewVia(yyData, $3, $4, $5, $6, $7, $8, $9, $10);
-				SaveFree($9);
+				free ($9);
 			}
 		;
 
@@ -743,7 +743,7 @@ via_2.0_format
 			{
 				CreateNewVia(yyData, $3*100, $4*100, $5*100, $6*100, $7*100, $8*100, $9,
 					OldFlags($10));
-				SaveFree($9);
+				free ($9);
 			}
 		;
 
@@ -754,7 +754,7 @@ via_1.7_format
 			{
 				CreateNewVia(yyData, $3*100, $4*100, $5*100, $6*100,
 					     ($5 + $6)*100, $7*100, $8, OldFlags($9));
-				SaveFree($8);
+				free ($8);
 			}
 		;
 
@@ -764,7 +764,7 @@ via_newformat
 			{
 				CreateNewVia(yyData, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME,
 					($5 + 2*MASKFRAME)*100,  $6*100, $7, OldFlags($8));
-				SaveFree($7);
+				free ($7);
 			}
 		;
 
@@ -781,7 +781,7 @@ via_oldformat
 
 				CreateNewVia(yyData, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME,
 					($5 + 2*MASKFRAME)*100, hole, $6, OldFlags($7));
-				SaveFree($6);
+				free ($6);
 			}
 		;
 
@@ -1045,7 +1045,7 @@ text_oldformat
 			{
 					/* use a default scale of 100% */
 				CreateNewText(Layer,yyFont,$3*100, $4*100, $5, 100, $6, OldFlags($7));
-				SaveFree($6);
+				free ($6);
 			}
 		;
 
@@ -1064,7 +1064,7 @@ text_newformat
 				else
 					CreateNewText(Layer, yyFont, $3*100, $4*100, $5, $6, $7,
 						      OldFlags($8));
-				SaveFree($7);
+				free ($7);
 			}
 		;
 text_hi_format
@@ -1087,7 +1087,7 @@ text_hi_format
 				}
 				else
 					CreateNewText(Layer, yyFont, $3, $4, $5, $6, $7, $8);
-				SaveFree($7);
+				free ($7);
 			}
 		;
 
@@ -1258,8 +1258,8 @@ element_oldformat
 			{
 				yyElement = CreateNewElement(yyData, yyElement, yyFont, NoFlags(),
 					$3, $4, NULL, $5*100, $6*100, $7, 100, NoFlags(), false);
-				SaveFree($3);
-				SaveFree($4);
+				free ($3);
+				free ($4);
 				pin_num = 1;
 			}
 		  elementdefinitions ')'
@@ -1276,8 +1276,8 @@ element_1.3.4_format
 			{
 				yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags($3),
 					$4, $5, NULL, $6*100, $7*100, $8, $9, OldFlags($10), false);
-				SaveFree($4);
-				SaveFree($5);
+				free ($4);
+				free ($5);
 				pin_num = 1;
 			}
 		  elementdefinitions ')'
@@ -1294,9 +1294,9 @@ element_newformat
 			{
 				yyElement = CreateNewElement(yyData, yyElement, yyFont, OldFlags($3),
 					$4, $5, $6, $7*100, $8*100, $9, $10, OldFlags($11), false);
-				SaveFree($4);
-				SaveFree($5);
-				SaveFree($6);
+				free ($4);
+				free ($5);
+				free ($6);
 				pin_num = 1;
 			}
 		  elementdefinitions ')'
@@ -1316,9 +1316,9 @@ element_1.7_format
 					$4, $5, $6, ($7+$9)*100, ($8+$10)*100, $11, $12, OldFlags($13), false);
 				yyElement->MarkX = $7*100;
 				yyElement->MarkY = $8*100;
-				SaveFree($4);
-				SaveFree($5);
-				SaveFree($6);
+				free ($4);
+				free ($5);
+				free ($6);
 			}
 		  relementdefs ')'
 			{
@@ -1337,9 +1337,9 @@ element_hi_format
 					$4, $5, $6, ($7+$9), ($8+$10), $11, $12, $13, false);
 				yyElement->MarkX = $7;
 				yyElement->MarkY = $8;
-				SaveFree($4);
-				SaveFree($5);
-				SaveFree($6);
+				free ($4);
+				free ($5);
+				free ($6);
 			}
 		  relementdefs ')'
 			{
@@ -1534,8 +1534,8 @@ pin_hi_format
 				CreateNewPin(yyElement, $3 + yyElement->MarkX,
 					$4 + yyElement->MarkY, $5, $6, $7, $8, $9,
 					$10, $11);
-				SaveFree($9);
-				SaveFree($10);
+				free ($9);
+				free ($10);
 			}
 		;
 pin_1.7_format
@@ -1546,8 +1546,8 @@ pin_1.7_format
 				CreateNewPin(yyElement, $3*100 + yyElement->MarkX,
 					$4*100 + yyElement->MarkY, $5*100, $6*100, $7*100, $8*100, $9,
 					$10, OldFlags($11));
-				SaveFree($9);
-				SaveFree($10);
+				free ($9);
+				free ($10);
 			}
 		;
 
@@ -1557,8 +1557,8 @@ pin_1.6.3_format
 			{
 				CreateNewPin(yyElement, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME,
 					($5 + 2*MASKFRAME)*100, $6*100, $7, $8, OldFlags($9));
-				SaveFree($7);
-				SaveFree($8);
+				free ($7);
+				free ($8);
 			}
 		;
 
@@ -1572,7 +1572,7 @@ pin_newformat
 				CreateNewPin(yyElement, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME,
 					($5 + 2*MASKFRAME)*100, $6*100, $7, p_number, OldFlags($8));
 
-				SaveFree($7);
+				free ($7);
 			}
 		;
 
@@ -1593,7 +1593,7 @@ pin_oldformat
 				sprintf(p_number, "%d", pin_num++);
 				CreateNewPin(yyElement, $3*100, $4*100, $5*100, 200*GROUNDPLANEFRAME,
 					($5 + 2*MASKFRAME)*100, hole, $6, p_number, OldFlags($7));
-				SaveFree($6);
+				free ($6);
 			}
 		;
 
@@ -1641,8 +1641,8 @@ pad_hi_format
 					$5 + yyElement->MarkX,
 					$6 + yyElement->MarkY, $7, $8, $9,
 					$10, $11, $12);
-				SaveFree($10);
-				SaveFree($11);
+				free ($10);
+				free ($11);
 			}
 		;
 
@@ -1654,8 +1654,8 @@ pad_1.7_format
 					$4*100 + yyElement->MarkY, $5*100 + yyElement->MarkX,
 					$6*100 + yyElement->MarkY, $7*100, $8*100, $9*100,
 					$10, $11, OldFlags($12));
-				SaveFree($10);
-				SaveFree($11);
+				free ($10);
+				free ($11);
 			}
 		;
 
@@ -1665,8 +1665,8 @@ pad_newformat
 			{
 				CreateNewPad(yyElement,$3*100,$4*100,$5*100,$6*100,$7*100, 200*GROUNDPLANEFRAME,
 					($7 + 2*MASKFRAME)*100, $8,$9, OldFlags($10));
-				SaveFree($8);
-				SaveFree($9);
+				free ($8);
+				free ($9);
 			}
 		;
 
@@ -1679,7 +1679,7 @@ pad
 				sprintf(p_number, "%d", pin_num++);
 				CreateNewPad(yyElement,$3*100,$4*100,$5*100,$6*100,$7*100, 200*GROUNDPLANEFRAME,
 					($7 + 2*MASKFRAME)*100, $8,p_number, OldFlags($9));
-				SaveFree($8);
+				free ($8);
 			}
 		;
 
@@ -1846,8 +1846,8 @@ net
 		: T_NET '(' STRING STRING ')' '('
 			{
 				Menu = CreateNewNet(&yyPCB->NetlistLib, $3, $4);
-				SaveFree($3);
-				SaveFree($4);
+				free ($3);
+				free ($4);
 			}
 		 connections ')'
 		;
@@ -1881,7 +1881,7 @@ conn
 		: T_CONN '(' STRING ')'
 			{
 				CreateNewConnection(Menu, $3);
-				SaveFree($3);
+				free ($3);
 			}
 		;
 
@@ -1914,8 +1914,8 @@ attribute
 		: T_ATTRIBUTE '(' STRING STRING ')'
 			{
 				CreateNewAttribute (attr_list, $3, $4 ? $4 : "");
-				SaveFree ($3);
-				SaveFree ($4);
+				free ($3);
+				free ($4);
 			}
 		;
 
diff --git a/src/rats.c b/src/rats.c
index 46a18c8..2ada575 100644
--- a/src/rats.c
+++ b/src/rats.c
@@ -228,15 +228,14 @@ ProcNetlist (LibraryTypePtr net_menu)
   if (!net_menu->MenuN)
     return (NULL);
   FreeNetListMemory (Wantlist);
-  SaveFree (Wantlist);
-  /*  MYFREE (Wantlist); *//* awkward */
+  free (Wantlist);
   badnet = false;
 
   /* find layer groups of the component side and solder side */
   SLayer = GetLayerGroupNumberByNumber (solder_silk_layer);
   CLayer = GetLayerGroupNumberByNumber (component_silk_layer);
 
-  Wantlist = MyCalloc (1, sizeof (NetListType), "ProcNetlist()");
+  Wantlist = calloc (1, sizeof (NetListType));
   if (Wantlist)
     {
       ALLPIN_LOOP (PCB->Data);
@@ -361,8 +360,7 @@ static bool
 CheckShorts (LibraryMenuTypePtr theNet)
 {
   bool new, warn = false;
-  PointerListTypePtr generic = MyCalloc (1, sizeof (PointerListType),
-					 "CheckShorts");
+  PointerListTypePtr generic = calloc (1, sizeof (PointerListType));
   /* the first connection was starting point so
    * the menu is always non-null
    */
@@ -442,7 +440,7 @@ CheckShorts (LibraryMenuTypePtr theNet)
   }
   ENDALL_LOOP;
   FreePointerListMemory (generic);
-  SaveFree (generic);
+  free (generic);
   return (warn);
 }
 
@@ -695,7 +693,7 @@ AddAllRats (bool SelectedOnly, void (*funcp) ())
   /* initialize finding engine */
   InitConnectionLookup ();
   SaveFindFlag (DRCFLAG);
-  Nets = MyCalloc (1, sizeof (NetListType), "AddAllRats()");
+  Nets = calloc (1, sizeof (NetListType));
   /* now we build another netlist (Nets) for each
    * net in Wantlist that shows how it actually looks now,
    * then fill in any missing connections with rat lines.
@@ -728,7 +726,8 @@ AddAllRats (bool SelectedOnly, void (*funcp) ())
   }
   END_LOOP;
   FreeNetListMemory (Nets);
-  MYFREE (Nets);
+  free (Nets);
+  Nets = NULL;
   FreeConnectionLookupMemory ();
   RestoreFindFlag ();
   if (funcp)
@@ -912,7 +911,7 @@ AddNet (void)
 	  return (NULL);
 	}
       entry = GetLibraryEntryMemory (menu);
-      entry->ListEntry = MyStrdup (name2, "AddNet");
+      entry->ListEntry = strdup (name2);
       netnode_to_netname (name2);
       goto ratIt;
     }
@@ -921,7 +920,7 @@ AddNet (void)
   if (menu)
     {
       entry = GetLibraryEntryMemory (menu);
-      entry->ListEntry = MyStrdup (name1, "AddNet");
+      entry->ListEntry = strdup (name1);
       netnode_to_netname (name1);
       goto ratIt;
     }
@@ -939,11 +938,11 @@ AddNet (void)
     }
 
   menu = GetLibraryMenuMemory (&PCB->NetlistLib);
-  menu->Name = MyStrdup (ratname, "AddNet");
+  menu->Name = strdup (ratname);
   entry = GetLibraryEntryMemory (menu);
-  entry->ListEntry = MyStrdup (name1, "AddNet");
+  entry->ListEntry = strdup (name1);
   entry = GetLibraryEntryMemory (menu);
-  entry->ListEntry = MyStrdup (name2, "AddNet");
+  entry->ListEntry = strdup (name2);
   menu->flag = 1;
 
 ratIt:
diff --git a/src/remove.c b/src/remove.c
index 98b9ade..8defaf4 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -120,7 +120,7 @@ RemovePCB (PCBTypePtr Ptr)
 {
   ClearUndoList (true);
   FreePCBMemory (Ptr);
-  SaveFree (Ptr);
+  free (Ptr);
 }
 
 /* ---------------------------------------------------------------------------
@@ -130,7 +130,7 @@ static void *
 DestroyVia (PinTypePtr Via)
 {
   r_delete_entry (DestroyTarget->via_tree, (BoxTypePtr) Via);
-  MYFREE (Via->Name);
+  free (Via->Name);
   if (Via != &DestroyTarget->Via[--DestroyTarget->ViaN])
     {
       *Via = DestroyTarget->Via[DestroyTarget->ViaN];
@@ -149,7 +149,7 @@ static void *
 DestroyLine (LayerTypePtr Layer, LineTypePtr Line)
 {
   r_delete_entry (Layer->line_tree, (BoxTypePtr) Line);
-  MYFREE (Line->Number);
+  free (Line->Number);
   if (Line != &Layer->Line[--Layer->LineN])
     {
       *Line = Layer->Line[Layer->LineN];
@@ -243,7 +243,7 @@ DestroyPolygonPoint (LayerTypePtr Layer,
 static void *
 DestroyText (LayerTypePtr Layer, TextTypePtr Text)
 {
-  MYFREE (Text->TextString);
+  free (Text->TextString);
   r_delete_entry (Layer->text_tree, (BoxTypePtr) Text);
   if (Text != &Layer->Text[--Layer->TextN])
     {
diff --git a/src/report.c b/src/report.c
index dc01153..7af4358 100644
--- a/src/report.c
+++ b/src/report.c
@@ -104,7 +104,7 @@ ReportDrills (int argc, char **argv, int x, int y)
   /* create dialog box */
   gui->report_dialog ("Drill Report", stringlist);
 
-  SaveFree (stringlist);
+  free (stringlist);
   return 0;
 }
 
diff --git a/src/undo.c b/src/undo.c
index 68ea8ff..5226c53 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -223,8 +223,7 @@ GetUndoSlot (int CommandType, int ID, int Kind)
 
       UndoMax += STEP_UNDOLIST;
       size = UndoMax * sizeof (UndoListType);
-      UndoList = (UndoListTypePtr) MyRealloc (UndoList, size,
-					      "AddCommandToUndoList()");
+      UndoList = (UndoListTypePtr) realloc (UndoList, size);
       memset (&UndoList[UndoN], 0, STEP_REMOVELIST * sizeof (UndoListType));
 
       /* ask user to flush the table because of it's size */
@@ -242,7 +241,7 @@ GetUndoSlot (int CommandType, int ID, int Kind)
     switch (ptr->Type)
       {
       case UNDO_CHANGENAME:
-	SaveFree (ptr->Data.ChangeName.Name);
+	free (ptr->Data.ChangeName.Name);
 	break;
       case UNDO_REMOVE:
 	type =
@@ -1211,9 +1210,10 @@ ClearUndoList (bool Force)
       for (undo = UndoList; UndoN; undo++, UndoN--)
 	{
 	  if (undo->Type == UNDO_CHANGENAME)
-	    SaveFree (undo->Data.ChangeName.Name);
+	    free (undo->Data.ChangeName.Name);
 	}
-      MYFREE (UndoList);
+      free (UndoList);
+      UndoList = NULL;
       if (RemoveList)
 	{
           FreeDataMemory (RemoveList);
-- 
1.7.1

From 27483fd7bd8e1c7b458491db34b28d1961250701 Mon Sep 17 00:00:00 2001
From: Peter Clifton <pcjc2@xxxxxxxxx>
Date: Tue, 7 Dec 2010 01:55:57 +0000
Subject: [PATCH 2/2] Fix some strdup calls which might be called with a NULL pointer

***** DOES NOT YET FIX ALL POSSIBLE CASES WHERE MyStrdup() WAS
      PREVIOUSLY USED AND WOULD PROVIDE THIS SAFE BEHAVIOUR

Addresses 6 out of ~51 cases

(And changes empty "\0" string handling in one those cases!)
---
 src/create.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/create.c b/src/create.c
index c965ac3..76a5478 100644
--- a/src/create.c
+++ b/src/create.c
@@ -259,7 +259,7 @@ CreateNewVia (DataTypePtr Data,
 	       0.01 * Via->DrillingHole, 0.01 * DrillingHole);
     }
 
-  Via->Name = strdup (Name);
+  Via->Name = (Name != NULL) ? strdup (Name) : NULL;
   Via->Flags = Flags;
   CLEAR_FLAG (WARNFLAG, Via);
   SET_FLAG (VIAFLAG, Via);
@@ -587,7 +587,7 @@ CreateNewText (LayerTypePtr Layer, FontTypePtr PCBFont,
   text->Direction = Direction;
   text->Flags = Flags;
   text->Scale = Scale;
-  text->TextString = strdup (TextString);
+  text->TextString = (TextString && *TextString) ? strdup (TextString) : NULL;
 
   /* calculate size of the bounding box */
   SetTextBoundingBox (PCBFont, text);
@@ -780,8 +780,8 @@ CreateNewPin (ElementTypePtr Element,
   pin->Thickness = Thickness;
   pin->Clearance = Clearance;
   pin->Mask = Mask;
-  pin->Name = strdup (Name);
-  pin->Number = strdup (Number);
+  pin->Name = (Name != NULL) ? strdup (Name) : NULL;
+  pin->Number = (Number != NULL) ? strdup (Number) : NULL;
   pin->Flags = Flags;
   CLEAR_FLAG (WARNFLAG, pin);
   SET_FLAG (PINFLAG, pin);
@@ -867,8 +867,8 @@ CreateNewPad (ElementTypePtr Element,
   pad->Thickness = Thickness;
   pad->Clearance = Clearance;
   pad->Mask = Mask;
-  pad->Name = strdup (Name);
-  pad->Number = strdup (Number);
+  pad->Name = (Name != NULL) ? strdup (Name) : NULL;
+  pad->Number = (Number != NULL) ? strdup (Number) : NULL;
   pad->Flags = Flags;
   CLEAR_FLAG (WARNFLAG, pad);
   pad->ID = ID++;
-- 
1.7.1


_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user