pcb 4.1.1
An interactive printed circuit board layout editor.

mymem.c File Reference

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"
Include dependency graph for mymem.c:

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)
RubberbandTypeGetRubberbandMemory (void)
 Get the next slot for a rubberband connection.
void ** GetPointerMemory (PointerListType *list)
void FreePointerListMemory (PointerListType *list)
BoxTypeGetBoxMemory (BoxListType *Boxes)
 Get the next slot for a box.
ConnectionTypeGetConnectionMemory (NetType *Net)
 Get the next slot for a connection.
NetTypeGetNetMemory (NetListType *Netlist)
 Get the next slot for a subnet.
NetListTypeGetNetListMemory (NetListListType *Netlistlist)
 Get the next slot for a net list.
PinTypeGetPinMemory (ElementType *element)
 Get the next slot for a pin.
static void FreePin (PinType *data)
PadTypeGetPadMemory (ElementType *element)
 Get the next slot for a pad.
static void FreePad (PadType *data)
PinTypeGetViaMemory (DataType *data)
 Get the next slot for a via.
static void FreeVia (PinType *data)
RatTypeGetRatMemory (DataType *data)
 Get the next slot for a Rat.
static void FreeRat (RatType *data)
LineTypeGetLineMemory (LayerType *layer)
 Get the next slot for a line.
static void FreeLine (LineType *data)
ArcTypeGetArcMemory (LayerType *layer)
 Get the next slot for an arc.
static void FreeArc (ArcType *data)
TextTypeGetTextMemory (LayerType *layer)
 Get the next slot for a text object.
static void FreeText (TextType *data)
PolygonTypeGetPolygonMemory (LayerType *layer)
 Get the next slot for a polygon object.
static void FreePolygon (PolygonType *data)
PointTypeGetPointMemoryInPolygon (PolygonType *Polygon)
 Get the next slot for a point in a polygon struct.
CardinalGetHoleIndexMemoryInPolygon (PolygonType *Polygon)
 Gets the next slot for a point in a polygon struct.
ElementTypeGetElementMemory (DataType *data)
 Get the next slot for an element.
static void FreeElement (ElementType *data)
LibraryMenuTypeGetLibraryMenuMemory (LibraryType *lib)
 Get the next slot for a library menu.
LibraryEntryTypeGetLibraryEntryMemory (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.
DrillTypeGetDrillInfoDrillMemory (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.

Detailed Description

Memory management functions.


Copyright.


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

Thomas.Nau@rz.uni-ulm.de

Definition in file mymem.c.


Function Documentation

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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().

static void FreeElement ( ElementType data) [static]

Definition at line 457 of file mymem.c.

Referenced by FreeDataMemory().

void FreeElementMemory ( ElementType element)
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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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)
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().

Here is the call graph for this function:

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().

ArcType* GetArcMemory ( LayerType layer)

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

PinType** GetDrillPinMemory ( DrillType Drill)

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

LineType* GetLineMemory ( LayerType layer)

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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().

RatType* GetRatMemory ( DataType data)

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().

Here is the call graph for this function:

TextType* GetTextMemory ( LayerType layer)

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().

PinType* GetViaMemory ( DataType data)

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.

Returns:
a pointer to the new 'duped' one or NULL if the old one holds only white space characters.

Definition at line 898 of file mymem.c.

References realloc().

Referenced by ActionLoadFrom(), and ghid_route_style_selector_edit_dialog().

Here is the call graph for this function: