Esempio n. 1
0
/* ---------------------------------------------------------------------------
 * free memory used by PCB
 */
void
FreePCBMemory (PCBTypePtr PCBPtr)
{
  int i;

  if (PCBPtr)
    {
      MYFREE (PCBPtr->Name);
      MYFREE (PCBPtr->Filename);
      MYFREE (PCBPtr->PrintFilename);
      if (PCBPtr->Data)
	FreeDataMemory (PCBPtr->Data);
      MYFREE (PCBPtr->Data);
      /* release font symbols */
      for (i = 0; i <= MAX_FONTPOSITION; i++)
	MYFREE (PCBPtr->Font.Symbol[i].Line);
      FreeLibraryMemory (&PCBPtr->NetlistLib);
      FreeAttributeListMemory (&PCBPtr->Attributes);
      /* clear struct */
      memset (PCBPtr, 0, sizeof (PCBType));
    }
  else
    {
      fprintf (stderr, "Warning:  Tried to FreePCBMemory(null)\n");
    }
}
Esempio n. 2
0
/*!
 * \brief Free the memory used by PCB.
 */
void
FreePCBMemory (PCBType *pcb) {
    int i;

    if (pcb == NULL) {
        return;
    }

    free (pcb->Name);
    free (pcb->Filename);
    free (pcb->PrintFilename);
    FreeDataMemory (pcb->Data);
    free (pcb->Data);

    /* release font symbols */
    for (i = 0; i <= MAX_FONTPOSITION; i++) {
        free (pcb->Font.Symbol[i].Line);
    }

    FreeLibraryMemory (&pcb->NetlistLib);
    NetlistChanged (0);
    FreeAttributeListMemory (&pcb->Attributes);
    /* clear struct */
    memset (pcb, 0, sizeof (PCBType));
}
Esempio n. 3
0
/*!
 * \brief The primary purpose of this action is to remove the netlist
 * completely so that a new one can be loaded, usually via a gsch2pcb
 * style script.
 */
static void
netlist_clear (LibraryMenuType * net, LibraryEntryType * pin)
{
  LibraryType *netlist = &PCB->NetlistLib;
  int ni, pi;

  if (net == 0)
    {
      /* Clear the entire netlist. */
      FreeLibraryMemory (&PCB->NetlistLib);
    }
  else if (pin == 0)
    {
      /* Remove a net from the netlist. */
      ni = net - netlist->Menu;
      if (ni >= 0 && ni < netlist->MenuN)
	{
	  /* if there is exactly one item, MenuN is 1 and ni is 0 */
	  if (netlist->MenuN - ni > 1)
	    memmove (net, net+1, (netlist->MenuN - ni - 1) * sizeof (*net));
	  netlist->MenuN --;
	}
    }
  else
    {
      /* Remove a pin from the given net.  Note that this may leave an
	 empty net, which is different than removing the net
	 (above).  */
      pi = pin - net->Entry;
      if (pi >= 0 && pi < net->EntryN)
	{
	  /* if there is exactly one item, MenuN is 1 and ni is 0 */
	  if (net->EntryN - pi > 1)
	    memmove (pin, pin+1, (net->EntryN - pi - 1) * sizeof (*pin));
	  net->EntryN --;
	}
    }
  NetlistChanged (0);
}