pcb 4.1.1
An interactive printed circuit board layout editor.
|
Memory management functions. More...
#include "global.h"
#include <memory.h>
#include "data.h"
#include "error.h"
#include "mymem.h"
#include "misc.h"
#include "rats.h"
#include "rtree.h"
Go to the source code of this file.
Functions | |
static void | DSRealloc (DynamicStringType *Ptr, size_t Length) |
Reallocates memory for a dynamic length string if necessary. | |
static void | g_list_free_full (GList *list, GDestroyNotify free_func) |
RubberbandType * | GetRubberbandMemory (void) |
Get the next slot for a rubberband connection. | |
void ** | GetPointerMemory (PointerListType *list) |
void | FreePointerListMemory (PointerListType *list) |
BoxType * | GetBoxMemory (BoxListType *Boxes) |
Get the next slot for a box. | |
ConnectionType * | GetConnectionMemory (NetType *Net) |
Get the next slot for a connection. | |
NetType * | GetNetMemory (NetListType *Netlist) |
Get the next slot for a subnet. | |
NetListType * | GetNetListMemory (NetListListType *Netlistlist) |
Get the next slot for a net list. | |
PinType * | GetPinMemory (ElementType *element) |
Get the next slot for a pin. | |
static void | FreePin (PinType *data) |
PadType * | GetPadMemory (ElementType *element) |
Get the next slot for a pad. | |
static void | FreePad (PadType *data) |
PinType * | GetViaMemory (DataType *data) |
Get the next slot for a via. | |
static void | FreeVia (PinType *data) |
RatType * | GetRatMemory (DataType *data) |
Get the next slot for a Rat. | |
static void | FreeRat (RatType *data) |
LineType * | GetLineMemory (LayerType *layer) |
Get the next slot for a line. | |
static void | FreeLine (LineType *data) |
ArcType * | GetArcMemory (LayerType *layer) |
Get the next slot for an arc. | |
static void | FreeArc (ArcType *data) |
TextType * | GetTextMemory (LayerType *layer) |
Get the next slot for a text object. | |
static void | FreeText (TextType *data) |
PolygonType * | GetPolygonMemory (LayerType *layer) |
Get the next slot for a polygon object. | |
static void | FreePolygon (PolygonType *data) |
PointType * | GetPointMemoryInPolygon (PolygonType *Polygon) |
Get the next slot for a point in a polygon struct. | |
Cardinal * | GetHoleIndexMemoryInPolygon (PolygonType *Polygon) |
Gets the next slot for a point in a polygon struct. | |
ElementType * | GetElementMemory (DataType *data) |
Get the next slot for an element. | |
static void | FreeElement (ElementType *data) |
LibraryMenuType * | GetLibraryMenuMemory (LibraryType *lib) |
Get the next slot for a library menu. | |
LibraryEntryType * | GetLibraryEntryMemory (LibraryMenuType *Menu) |
Get the next slot for a library entry. | |
ElementType ** | GetDrillElementMemory (DrillType *Drill) |
Get the next slot for a DrillElement. | |
PinType ** | GetDrillPinMemory (DrillType *Drill) |
Get the next slot for a DrillPoint. | |
DrillType * | GetDrillInfoDrillMemory (DrillInfoType *DrillInfo) |
Get the next slot for a Drill. | |
void | FreePolygonMemory (PolygonType *polygon) |
Free the memory used by a polygon. | |
void | FreeBoxListMemory (BoxListType *Boxlist) |
Free the memory used by a box list. | |
void | FreeNetListMemory (NetListType *Netlist) |
Free the memory used by a net. | |
void | FreeNetListListMemory (NetListListType *Netlistlist) |
Free the memory used by a net list. | |
void | FreeNetMemory (NetType *Net) |
Free the memory used by a subnet. | |
static void | FreeAttributeListMemory (AttributeListType *list) |
Free the memory used by an attribute list. | |
void | FreeElementMemory (ElementType *element) |
Free the memory used by an element. | |
void | FreePCBMemory (PCBType *pcb) |
Free the memory used by PCB. | |
void | FreeDataMemory (DataType *data) |
Free the memory used by data struct. | |
void | FreeLibraryMemory (LibraryType *lib) |
Free the memory that's allocated by the library. | |
void | DSAddCharacter (DynamicStringType *Ptr, char Char) |
Adds one character to a dynamic string. | |
void | DSAddString (DynamicStringType *Ptr, const char *S) |
Add a string to a dynamic string. | |
void | DSClearString (DynamicStringType *Ptr) |
Clear a dynamic string. | |
char * | StripWhiteSpaceAndDup (const char *S) |
Strips leading and trailing blanks from the passed string. |
Memory management functions.
PCB, interactive printed circuit board design
Copyright (C) 1994,1995,1996 Thomas Nau
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Contact addresses for paper mail and Email:
Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
Definition in file mymem.c.
void DSAddCharacter | ( | DynamicStringType * | Ptr, |
char | Char | ||
) |
Adds one character to a dynamic string.
Definition at line 857 of file mymem.c.
References DynamicStringType::Data, and DSRealloc().
Referenced by CreateQuotedString(), EvaluateFilename(), ExpandFilename(), and WritePipe().
void DSAddString | ( | DynamicStringType * | Ptr, |
const char * | S | ||
) |
Add a string to a dynamic string.
Definition at line 870 of file mymem.c.
References DynamicStringType::Data, and DSRealloc().
Referenced by EvaluateFilename(), GetInfoString(), ReportFoundPins(), and WritePipe().
void DSClearString | ( | DynamicStringType * | Ptr | ) |
Clear a dynamic string.
Definition at line 885 of file mymem.c.
References DynamicStringType::Data.
Referenced by CreateQuotedString(), EvaluateFilename(), ExpandFilename(), ReportFoundPins(), and WritePipe().
static void DSRealloc | ( | DynamicStringType * | Ptr, |
size_t | Length | ||
) | [static] |
Reallocates memory for a dynamic length string if necessary.
Definition at line 841 of file mymem.c.
References DynamicStringType::Data, DynamicStringType::MaxLength, and realloc().
Referenced by DSAddCharacter(), and DSAddString().
static void FreeArc | ( | ArcType * | data | ) | [static] |
Definition at line 340 of file mymem.c.
Referenced by FreeDataMemory(), and FreeElementMemory().
static void FreeAttributeListMemory | ( | AttributeListType * | list | ) | [static] |
Free the memory used by an attribute list.
Definition at line 659 of file mymem.c.
References AttributeListType::List, AttributeListType::Max, AttributeType::name, AttributeListType::Number, and AttributeType::value.
Referenced by FreeDataMemory(), FreeElementMemory(), and FreePCBMemory().
void FreeBoxListMemory | ( | BoxListType * | Boxlist | ) |
Free the memory used by a box list.
Definition at line 598 of file mymem.c.
References BoxListType::Box.
Referenced by ComputeCost().
void FreeDataMemory | ( | DataType * | data | ) |
Free the memory used by data struct.
Definition at line 739 of file mymem.c.
References LayerType::Arc, LayerType::arc_tree, LayerType::Attributes, DataType::Element, ELEMENT_LOOP, DataType::element_tree, END_LOOP, FreeArc(), FreeAttributeListMemory(), FreeElement(), FreeElementMemory(), FreeLine(), FreePolygon(), FreePolygonMemory(), FreeRat(), FreeText(), FreeVia(), g_list_free_full(), DataType::Layer, layer, LayerType::Line, line, LINE_LOOP, LayerType::line_tree, MAX_ALL_LAYER, LayerType::Name, DataType::name_tree, LineType::Number, DataType::pad_tree, DataType::pin_tree, LayerType::Polygon, POLYGON_LOOP, LayerType::polygon_tree, r_destroy_tree(), DataType::Rat, DataType::rat_tree, LayerType::Text, TEXT_LOOP, LayerType::text_tree, DataType::Via, VIA_LOOP, and DataType::via_tree.
Referenced by ClearBuffer(), ClearUndoList(), and FreePCBMemory().
static void FreeElement | ( | ElementType * | data | ) | [static] |
Definition at line 457 of file mymem.c.
Referenced by FreeDataMemory().
void FreeElementMemory | ( | ElementType * | element | ) |
Free the memory used by an element.
Definition at line 677 of file mymem.c.
References ElementType::Arc, ElementType::Attributes, ELEMENTNAME_LOOP, END_LOOP, FreeArc(), FreeAttributeListMemory(), FreeLine(), FreePad(), FreePin(), g_list_free_full(), ElementType::Line, pin_st::Name, pin_st::Number, ElementType::Pad, PAD_LOOP, ElementType::Pin, pin, and PIN_LOOP.
Referenced by DestroyElement(), FreeDataMemory(), pinout_set_data(), and SmashBufferElement().
void FreeLibraryMemory | ( | LibraryType * | lib | ) |
Free the memory that's allocated by the library.
Definition at line 817 of file mymem.c.
References END_LOOP, ENTRY_LOOP, LibraryType::Menu, and MENU_LOOP.
Referenced by ActionLoadFrom(), FreePCBMemory(), and netlist_clear().
static void FreeLine | ( | LineType * | data | ) | [static] |
Definition at line 317 of file mymem.c.
Referenced by FreeDataMemory(), and FreeElementMemory().
void FreeNetListListMemory | ( | NetListListType * | Netlistlist | ) |
Free the memory used by a net list.
Definition at line 629 of file mymem.c.
References END_LOOP, FreeNetListMemory(), NetListListType::NetList, and NETLIST_LOOP.
Referenced by CreateRouteData(), and import_clusters().
void FreeNetListMemory | ( | NetListType * | Netlist | ) |
Free the memory used by a net.
Definition at line 611 of file mymem.c.
References END_LOOP, FreeNetMemory(), NetListType::Net, and NET_LOOP.
Referenced by AddAllRats(), FreeNetListListMemory(), and ProcNetlist().
void FreeNetMemory | ( | NetType * | Net | ) |
Free the memory used by a subnet.
Definition at line 647 of file mymem.c.
References NetType::Connection.
Referenced by DrawShortestRats(), FreeNetListMemory(), and TransferNet().
static void FreePad | ( | PadType * | data | ) | [static] |
Definition at line 248 of file mymem.c.
Referenced by FreeElementMemory().
void FreePCBMemory | ( | PCBType * | pcb | ) |
Free the memory used by PCB.
Definition at line 713 of file mymem.c.
References PCBType::Attributes, PCBType::Data, PCBType::Filename, PCBType::Font, FreeAttributeListMemory(), FreeDataMemory(), FreeLibraryMemory(), SymbolType::Line, PCBType::Name, NetlistChanged(), PCBType::NetlistLib, PCBType::PrintFilename, and FontType::Symbol.
Referenced by pcb_main_uninit(), and RemovePCB().
static void FreePin | ( | PinType * | data | ) | [static] |
Definition at line 225 of file mymem.c.
Referenced by FreeElementMemory().
void FreePointerListMemory | ( | PointerListType * | list | ) |
Definition at line 112 of file mymem.c.
References PointerListType::Ptr.
Referenced by AutoPlaceSelected(), CheckShorts(), ComputeCost(), and CreateRouteData().
static void FreePolygon | ( | PolygonType * | data | ) | [static] |
Definition at line 386 of file mymem.c.
Referenced by FreeDataMemory().
void FreePolygonMemory | ( | PolygonType * | polygon | ) |
Free the memory used by a polygon.
Definition at line 579 of file mymem.c.
References polygon_st::Clipped, polygon_st::HoleIndex, polygon_st::NoHoles, polygon_st::Points, poly_Free(), and poly_FreeContours().
Referenced by DestroyCrosshair(), DestroyPolygon(), and FreeDataMemory().
static void FreeRat | ( | RatType * | data | ) | [static] |
Definition at line 294 of file mymem.c.
Referenced by FreeDataMemory().
static void FreeText | ( | TextType * | data | ) | [static] |
Definition at line 363 of file mymem.c.
Referenced by FreeDataMemory().
static void FreeVia | ( | PinType * | data | ) | [static] |
Definition at line 271 of file mymem.c.
Referenced by FreeDataMemory().
static void g_list_free_full | ( | GList * | list, |
GDestroyNotify | free_func | ||
) | [static] |
Definition at line 63 of file mymem.c.
Referenced by FreeDataMemory(), and FreeElementMemory().
Get the next slot for an arc.
Allocates memory if necessary.
Definition at line 328 of file mymem.c.
References LayerType::Arc, and LayerType::ArcN.
Referenced by CreateNewArcOnLayer().
BoxType* GetBoxMemory | ( | BoxListType * | Boxes | ) |
Get the next slot for a box.
Allocates memory if necessary.
Definition at line 124 of file mymem.c.
References BoxListType::Box, box, BoxListType::BoxMax, BoxListType::BoxN, realloc(), and STEP_POINT.
Referenced by ComputeCost().
ConnectionType* GetConnectionMemory | ( | NetType * | Net | ) |
Get the next slot for a connection.
Allocates memory if necessary.
Definition at line 147 of file mymem.c.
References NetType::Connection, NetType::ConnectionMax, NetType::ConnectionN, realloc(), and STEP_POINT.
Referenced by AddAllRats(), CollectSubnets(), GatherSubnets(), ProcNetlist(), and TransferNet().
ElementType** GetDrillElementMemory | ( | DrillType * | Drill | ) |
Get the next slot for a DrillElement.
Allocates memory if necessary.
Definition at line 512 of file mymem.c.
References DrillType::Element, DrillType::ElementMax, DrillType::ElementN, realloc(), and STEP_ELEMENT.
Referenced by FillDrill(), and InitializeDrill().
DrillType* GetDrillInfoDrillMemory | ( | DrillInfoType * | DrillInfo | ) |
Get the next slot for a Drill.
Allocates memory if necessary.
Definition at line 560 of file mymem.c.
References DrillInfoType::Drill, DrillInfoType::DrillMax, DrillInfoType::DrillN, realloc(), and STEP_DRILL.
Referenced by GetDrillInfo().
Get the next slot for a DrillPoint.
Allocates memory if necessary.
Definition at line 537 of file mymem.c.
References DrillType::Pin, pin, DrillType::PinMax, DrillType::PinN, realloc(), and STEP_POINT.
Referenced by FillDrill(), and InitializeDrill().
ElementType* GetElementMemory | ( | DataType * | data | ) |
Get the next slot for an element.
Allocates memory if necessary.
Definition at line 441 of file mymem.c.
References DataType::Element, and DataType::ElementN.
Referenced by CreateNewElement().
Cardinal* GetHoleIndexMemoryInPolygon | ( | PolygonType * | Polygon | ) |
Gets the next slot for a point in a polygon struct.
Allocates memory if necessary.
Definition at line 419 of file mymem.c.
References polygon_st::HoleIndex, polygon_st::HoleIndexMax, polygon_st::HoleIndexN, realloc(), and STEP_POLYGONHOLEINDEX.
Referenced by CreateNewHoleInPolygon().
LibraryEntryType* GetLibraryEntryMemory | ( | LibraryMenuType * | Menu | ) |
Get the next slot for a library entry.
Allocates memory if necessary.
Definition at line 490 of file mymem.c.
References LibraryMenuType::Entry, LibraryMenuType::EntryMax, LibraryMenuType::EntryN, realloc(), and STEP_LIBRARYENTRY.
Referenced by AddNet(), CreateNewConnection(), define_pcb_net(), LoadNewlibFootprintsFromDir(), ReadLibraryContents(), and ReadNetlist().
LibraryMenuType* GetLibraryMenuMemory | ( | LibraryType * | lib | ) |
Get the next slot for a library menu.
Allocates memory if necessary.
Definition at line 468 of file mymem.c.
References LibraryType::Menu, LibraryType::MenuMax, LibraryType::MenuN, realloc(), and STEP_LIBRARYMENU.
Referenced by AddNet(), CreateNewNet(), define_pcb_net(), LoadNewlibFootprintsFromDir(), ReadLibraryContents(), and ReadNetlist().
Get the next slot for a line.
Allocates memory if necessary.
Definition at line 305 of file mymem.c.
References LayerType::Line, and LayerType::LineN.
Referenced by CreateNewLineOnLayer().
NetListType* GetNetListMemory | ( | NetListListType * | Netlistlist | ) |
Get the next slot for a net list.
Allocates memory if necessary.
Definition at line 190 of file mymem.c.
References NetListListType::NetList, NetListListType::NetListMax, NetListListType::NetListN, realloc(), and STEP_POINT.
Referenced by CollectSubnets().
NetType* GetNetMemory | ( | NetListType * | Netlist | ) |
Get the next slot for a subnet.
Allocates memory if necessary.
Definition at line 169 of file mymem.c.
References NetListType::Net, NetListType::NetMax, NetListType::NetN, realloc(), and STEP_POINT.
Referenced by AddAllRats(), CollectSubnets(), and ProcNetlist().
PadType* GetPadMemory | ( | ElementType * | element | ) |
Get the next slot for a pad.
Allocates memory if necessary.
Definition at line 236 of file mymem.c.
References ElementType::Pad, and ElementType::PadN.
Referenced by CreateNewPad().
PinType* GetPinMemory | ( | ElementType * | element | ) |
Get the next slot for a pin.
Allocates memory if necessary.
Definition at line 213 of file mymem.c.
References ElementType::Pin, and ElementType::PinN.
Referenced by CreateNewPin().
void** GetPointerMemory | ( | PointerListType * | list | ) |
Definition at line 95 of file mymem.c.
References PointerListType::Ptr, ptr, PointerListType::PtrMax, PointerListType::PtrN, realloc(), and STEP_POINT.
Referenced by AddIrregularObstacle(), AddLine(), AddPad(), AddPin(), CheckShorts(), collectSelectedElements(), and ComputeCost().
PointType* GetPointMemoryInPolygon | ( | PolygonType * | Polygon | ) |
Get the next slot for a point in a polygon struct.
Allocates memory if necessary.
Definition at line 397 of file mymem.c.
References polygon_st::PointMax, polygon_st::PointN, polygon_st::Points, realloc(), and STEP_POLYGONPOINT.
Referenced by CreateNewPointInPolygon().
PolygonType* GetPolygonMemory | ( | LayerType * | layer | ) |
Get the next slot for a polygon object.
Allocates memory if necessary.
Definition at line 374 of file mymem.c.
References LayerType::Polygon, and LayerType::PolygonN.
Referenced by CreateNewPolygon().
Get the next slot for a Rat.
Allocates memory if necessary.
Definition at line 282 of file mymem.c.
References DataType::Rat, and DataType::RatN.
Referenced by CreateNewRat().
RubberbandType* GetRubberbandMemory | ( | void | ) |
Get the next slot for a rubberband connection.
Allocates memory if necessary.
Definition at line 76 of file mymem.c.
References CrosshairType::AttachedObject, Crosshair, ptr, realloc(), AttachedObjectType::Rubberband, AttachedObjectType::RubberbandMax, AttachedObjectType::RubberbandN, and STEP_RUBBERBAND.
Referenced by CreateNewRubberbandEntry().
Get the next slot for a text object.
Allocates memory if necessary.
Definition at line 351 of file mymem.c.
References LayerType::Text, and LayerType::TextN.
Referenced by CreateNewText().
Get the next slot for a via.
Allocates memory if necessary.
Definition at line 259 of file mymem.c.
References DataType::Via, and DataType::ViaN.
Referenced by CreateNewVia().
char* StripWhiteSpaceAndDup | ( | const char * | S | ) |
Strips leading and trailing blanks from the passed string.
Definition at line 898 of file mymem.c.
References realloc().
Referenced by ActionLoadFrom(), and ghid_route_style_selector_edit_dialog().