Compare commits

...

22 Commits

Author SHA1 Message Date
R. Timothy Edwards 949ec7672c Reworked the code from the previous commit in a completely different
way.  The code as previously written was undermining other code
written to avoid long run-times on ext2spice, and didn't solve at
least one issue with unnecessary resistor shorts being added to the
netlist output.  The current solution fixes one underlying problem
where a wrongly-placed parenthesis caused the "preferred net name"
routine EFHNBest() not to be run, which prevented original node
names from being preferred over their suffixed versions created by
"extract unique".  However, I also added code to EFbuild.c to
merge unique nodes when the nodes are not really unique.  The
problem is caused by "extract unique" operating only on one level
of hierarchy and being unable to see where nets may connect through
subcircuits.  That can be determined from the "merge" statements
in the .ext file, and now the EFbuild routines will merge these
"false unique" names back into the original net.
2025-12-24 16:00:08 -05:00
R. Timothy Edwards bd417aa54b Updating the version number to go along with the merge of pull
request #478 from Mitch Bailey.  Also edited the code from the
PR for programming style.
2025-12-24 11:31:43 -05:00
Mitch Bailey 73e08e0c88 Prefer original ports over duplicate ports in extracted spice netlist.
Prioritize lowest port number when merging nodes.

Signed-off-by: Mitch Bailey <d.mitch.bailey@gmail.com>
2025-12-24 11:19:16 -05:00
R. Timothy Edwards 893a36cae7 Updated the version to go along with the merge of pull requests
475, 476, and 477 (first ones for mac OS and arch Linux support
on github;  the last to modify recent code changes to work with
the last code merge for eliminating the one-off freeMagic().
2025-12-22 09:57:56 -05:00
Darryl L. Miles 3b4d66e7d7 freeMagic1() additions
These additional uses of freeMagic() also require defer-by-one using stack
storage (not global storage idiom, recently introduced).
Not sure if they were missed original or new/modified code in the past
12 months.  Some areas/line-of-code are not usually compiled, maybe that
is why they were originally missed.
2025-12-22 09:57:42 -05:00
Darryl L. Miles 5e8a3f038a CalmaWrite: fix: introduced memory leak, missed free
Appears the 'listtop' is a sentinal/entryexit value to a circular list
My recent patch does not copy original behaviour in freeing this list
entry (as well as the reset of the list).
2025-12-22 09:57:42 -05:00
Darryl L. Miles 9850c5586e GHA: main-aarch64.yml: insert apt-get update 2025-12-22 09:57:29 -05:00
Darryl L. Miles 27df5f9c5f GHA: Migrate macos-13 => macos-15-intel 2025-12-22 09:57:04 -05:00
Darryl L. Miles e9202c1d29 malloc: remove #pragma weak as MacOS does not like
Originally the use of a weak symbol was to provide a fallback for
non-inline supporting compilers.  However all compilers (we care about)
support inline keyword (which was not known at the original time of the
work).  Furthermore GCC have already worked through the solution and make
it easy to implement.

The use of __GNUC_STDC_INLINE__ pattern in this way manages the fallback
and emits a hard symbol this can be tested with:

CFLAGS="-g" ./configure; make; nm */lib*.o | grep freeMagic1

CFLAGS="-O3" ./configure; make; nm */lib*.o | grep freeMagic1

A hard 'T' symbol is emitted (to provide fallback) with all builds, but
in the -O3 all usage is inlined.  So an individual file can decide to
inline or not at the occasion (compile time options) allows.
2025-12-19 09:31:58 -05:00
Darryl L. Miles ea1a89b19c EFbuild.c: efConnectionFreeLinkedList() remove delay-by-one assumption
freeMagic1 series 2nd order find
2025-12-19 09:31:58 -05:00
Darryl L. Miles 9489b23985 freeMagic1() idiom insertion at all sites reported by static code analysis 2025-12-19 09:31:58 -05:00
Darryl L. Miles c74215ad55 scripts/defs.mak.in: FEATURE_FLAGS -DSUPPORT_DIRECT_MALLOC -DSUPPORT_REMOVE_MALLOC_LEGACY
./configure
 # If you are brave, enable with your favourite editor after ./configure
 sed -e 's/^#FEATURE_FLAGS /FEATURE_FLAGS /' -i defs.mak
 make
 make install
2025-12-19 09:31:58 -05:00
Darryl L. Miles 4201f56048 callocMagic has same API argument convention as calloc() 2025-12-19 09:31:58 -05:00
Darryl L. Miles 26372f5d50 gtTkCommon.c: SUPPORT_DIRECT_MALLOC around function pointer use of legacy malloc
Just in case I also modify the allocation to ensure it was also performed
via exactly the same method.
2025-12-19 09:31:58 -05:00
Darryl L. Miles ef419258ab SUPPORT_DIRECT_MALLOC and SUPPORT_REMOVE_MALLOC_LEGACY
This supports three build modes:

No additional -D options, default legacy mode

-DSUPPORT_DIRECT_MALLOC, magic will use direct calls to libc malloc/free
 and will leave in place the symbols now renamed as mallocMagicLegacy()
 freeMagicLegacy() and callocMagicLegacy().

-DSUPPORT_DIRECT_MALLOC -DSUPPORT_REMOVE_MALLOC_LEGACY as above but will
 remove the three legacy functions from the binary to provide assurance
 they can not be used.

The system malloc is thread-safe the legacy magic malloc has a global
deferred free pointer and the mmap() allocate has a free-list that is
not thread-safe making use of free not thread-safe.
This could of course be improved with the use of
atomic_compare_and_exchange operations but for what gain ?

Then there is the additional function call overhead (of the indirection)
and a few tests/branches inserted into a commonly used code paths around
memory allocation, it hides the call site of the malloc/free usage from
the compiler which maybe have special optimization cases.

The existing malloc/free makes static code analysis around memory
allocation more problematic, also use of runtime analysers will operate
better with a fail-fast to bad memory usage.
2025-12-19 09:31:58 -05:00
R. Timothy Edwards 97134848ab A few minor changes to message reporting, plus some additional
support for compressed formats, specifically when given on the
command line (which is handled in a Tcl script, not in the C
code).
2025-12-19 09:30:35 -05:00
R. Timothy Edwards 00c692b140 Added better support for compressed .mag files. While magic doesn't
generate compressed .mag files itself, it is often very useful to
compress a massive layout file to save disk space or to hit a github
size target.  The code change looks for files with either ".mag" (default)
or ".mag.gz" extensions.  No check is made to see if both files might
exist at the same time and have incompatible content;  it is up to the
end user to manage the file compression.
2025-12-11 09:55:28 -05:00
R. Timothy Edwards 203ece1a16 Fixed the "interacting" GDS output operator (which includes
"noninteracting", "overlapping", and "nonoverlapping") which
were incorrectly ignoring tiles outside the search area.
Otherwise they will miss areas that pass outside of the the
search area and return back inside somewhere else.
2025-12-01 15:16:14 -05:00
R. Timothy Edwards 22a230edc9 Found a mistake in the original edit for time stamps from two
commits back, and fixed it.  Also found that the version was
changed between today's first two commits, which it should not
have been, so dialed it back.
2025-11-29 15:49:17 -05:00
R. Timothy Edwards 7f1217596e Missed one additional place in the last commit where timestamps
need to be predecated on the read/write status of cells.
2025-11-29 15:01:21 -05:00
R. Timothy Edwards ff718c3ecf Got rid of one problem with timestamps, which was the requirement
to force an update on a child cell to match the timestamp of the
parent.  This is no longer done on read-only cells, although it
probably ought to be applied to all cells.  A timestamp should
change when a cell has been modified, but a parent cell should never
force a child cell to update its timestamp if the child cell has
not been modified.  The main problem is that "drc check" runs checks
on all child cells, and they then are marked as modified without
consideration of whether the child's DRC status changed.  A better
solution would be to avoid unnecessary updates by detecting a
change in DRC results, but for now, just disabling updates on
read-only cells (which can't be updated anyway) should suffice.
2025-11-29 13:24:23 -05:00
R. Timothy Edwards 98aa2f760a Corrected an error from a recent commit: An attempt to add array
checks when checking for exactly overlapping instances of the same
cell def was faulty and resulted in magic no longer detecting when
unarrayed instances exactly overlap.  Now both conditions (arrayed
and not arrayed) should be handled correctly.
2025-11-25 12:57:46 -05:00
91 changed files with 1036 additions and 312 deletions

View File

@ -16,6 +16,7 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Get Dependencies - name: Get Dependencies
run: | run: |
sudo apt-get update
sudo apt-get install -y tcl-dev tk-dev libcairo-dev sudo apt-get install -y tcl-dev tk-dev libcairo-dev
- name: Build - name: Build
run: | run: |

View File

@ -10,8 +10,8 @@ on:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel # A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs: jobs:
simple_build_macos13: simple_build_macos15:
runs-on: macos-13 runs-on: macos-15-intel # only and last supported intel MacOS
timeout-minutes: 45 # x86_64 seems non-SSD based (slower) timeout-minutes: 45 # x86_64 seems non-SSD based (slower)
steps: steps:
- name: Checkout - name: Checkout
@ -235,10 +235,10 @@ jobs:
cp *.mak dist/BUILD-INFO/ cp *.mak dist/BUILD-INFO/
cp *.LOG dist/BUILD-INFO/ cp *.LOG dist/BUILD-INFO/
- name: Upload archive magic-macos13 - name: Upload archive magic-macos15
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: magic-macos13 name: magic-macos15
path: | path: |
${{ github.workspace }}/dist ${{ github.workspace }}/dist

View File

@ -1 +1 @@
8.3.578 8.3.585

View File

@ -93,7 +93,7 @@ static BinArray *bpBinArrayNew(int dx, /* x diameter of bins */
/* allocate array */ /* allocate array */
size = sizeof(BinArray) + numBins*(sizeof(void *)); size = sizeof(BinArray) + numBins*(sizeof(void *));
new = (BinArray *)callocMagic(size); new = (BinArray *)callocMagic(1, size);
/* initial */ /* initial */
new->ba_bbox = *bbox; new->ba_bbox = *bbox;

View File

@ -360,12 +360,14 @@ calmaElementBoundary(void)
} }
/* Paint the rectangles (if any) */ /* Paint the rectangles (if any) */
free_magic1_t mm1 = freeMagic1_init();
for (; rp != NULL ; rp = rp->r_next) for (; rp != NULL ; rp = rp->r_next)
{ {
if (plane) if (plane)
DBPaintPlane(plane, &rp->r_r, CIFPaintTable, (PaintUndoInfo *)NULL); DBPaintPlane(plane, &rp->r_r, CIFPaintTable, (PaintUndoInfo *)NULL);
freeMagic((char *) rp); freeMagic1(&mm1, (char *) rp);
} }
freeMagic1_end(&mm1);
if (cifCurReadPlanes == cifEditCellPlanes) if (cifCurReadPlanes == cifEditCellPlanes)
{ {

View File

@ -1400,8 +1400,10 @@ calmaOutFunc(
{ {
pllist[i].pl_label = ll->ll_label; pllist[i].pl_label = ll->ll_label;
pllist[i].pl_port = (unsigned int)ll->ll_attr; pllist[i].pl_port = (unsigned int)ll->ll_attr;
freeMagic(ll); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, ll);
ll = ll->ll_next; ll = ll->ll_next;
freeMagic1_end(&mm1);
i++; i++;
} }
@ -2422,19 +2424,27 @@ calmaProcessBoundary(
/* Free the LinkedBoundary list */ /* Free the LinkedBoundary list */
lbref = listtop;
while (lbref->lb_next != listtop)
{ {
freeMagic(lbref); free_magic1_t mm1 = freeMagic1_init();
lbref = lbref->lb_next; lbref = listtop;
while (lbref->lb_next != listtop)
{
freeMagic1(&mm1, lbref);
lbref = lbref->lb_next;
}
freeMagic1(&mm1, lbref);
freeMagic1_end(&mm1);
} }
freeMagic(lbref);
} }
/* Free the BoundaryTop list */ /* Free the BoundaryTop list */
for (bounds = blist; bounds != NULL; bounds = bounds->bt_next) {
freeMagic(bounds); free_magic1_t mm1 = freeMagic1_init();
for (bounds = blist; bounds != NULL; bounds = bounds->bt_next)
freeMagic1(&mm1, bounds);
freeMagic1_end(&mm1);
}
} }
/* /*
@ -2500,8 +2510,10 @@ calmaMergePaintFunc(
lb = edge; lb = edge;
while (lb->lb_next != edge) lb = lb->lb_next; while (lb->lb_next != edge) lb = lb->lb_next;
lb->lb_next = edge->lb_next; lb->lb_next = edge->lb_next;
freeMagic(edge); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, edge);
edge = edge->lb_next; edge = edge->lb_next;
freeMagic1_end(&mm1);
} }
} }
else else
@ -2720,11 +2732,13 @@ done_searches:
if (num_points != 4) if (num_points != 4)
{ {
free_magic1_t mm1 = freeMagic1_init();
for (i = 0; i < num_points; i++) for (i = 0; i < num_points; i++)
{ {
freeMagic(edge); freeMagic1(&mm1, edge);
edge = edge->lb_next; edge = edge->lb_next;
} }
freeMagic1_end(&mm1);
edge = NULL; edge = NULL;
} }
if (!StackEmpty(SegStack)) if (!StackEmpty(SegStack))

View File

@ -1324,8 +1324,10 @@ calmaOutFuncZ(
{ {
pllist[i].pl_label = ll->ll_label; pllist[i].pl_label = ll->ll_label;
pllist[i].pl_port = (unsigned int)ll->ll_attr; pllist[i].pl_port = (unsigned int)ll->ll_attr;
freeMagic(ll); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, ll);
ll = ll->ll_next; ll = ll->ll_next;
freeMagic1_end(&mm1);
i++; i++;
} }
@ -1857,19 +1859,27 @@ calmaProcessBoundaryZ(
/* Free the LinkedBoundary list */ /* Free the LinkedBoundary list */
lbref = listtop;
while (lbref->lb_next != listtop)
{ {
freeMagic(lbref); free_magic1_t mm1 = freeMagic1_init();
lbref = lbref->lb_next; lbref = listtop;
while (lbref->lb_next != listtop)
{
freeMagic1(&mm1, lbref);
lbref = lbref->lb_next;
}
freeMagic1(&mm1, lbref);
freeMagic1_end(&mm1);
} }
freeMagic(lbref);
} }
/* Free the BoundaryTop list */ /* Free the BoundaryTop list */
for (bounds = blist; bounds != NULL; bounds = bounds->bt_next) {
freeMagic(bounds); free_magic1_t mm1 = freeMagic1_init();
for (bounds = blist; bounds != NULL; bounds = bounds->bt_next)
freeMagic1(&mm1, bounds);
freeMagic1_end(&mm1);
}
} }
/* /*
@ -1935,8 +1945,10 @@ calmaMergePaintFuncZ(
lb = edge; lb = edge;
while (lb->lb_next != edge) lb = lb->lb_next; while (lb->lb_next != edge) lb = lb->lb_next;
lb->lb_next = edge->lb_next; lb->lb_next = edge->lb_next;
freeMagic(edge); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, edge);
edge = edge->lb_next; edge = edge->lb_next;
freeMagic1_end(&mm1);
} }
} }
else else
@ -2155,11 +2167,13 @@ done_searches:
if (num_points != 4) if (num_points != 4)
{ {
free_magic1_t mm1 = freeMagic1_init();
for (i = 0; i < num_points; i++) for (i = 0; i < num_points; i++)
{ {
freeMagic(edge); freeMagic1(&mm1, edge);
edge = edge->lb_next; edge = edge->lb_next;
} }
freeMagic1_end(&mm1);
edge = NULL; edge = NULL;
} }
if (!StackEmpty(SegStack)) if (!StackEmpty(SegStack))

View File

@ -2783,8 +2783,10 @@ cifSquaresFillArea(
DBPaintPlane(plane, &stripList->area, CIFEraseTable, DBPaintPlane(plane, &stripList->area, CIFEraseTable,
(PaintUndoInfo *) NULL); (PaintUndoInfo *) NULL);
freeMagic(stripList); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, stripList);
stripList = stripList->strip_next; stripList = stripList->strip_next;
freeMagic1_end(&mm1);
} }
/* 2nd pass: Search the plane for unmarked tiles */ /* 2nd pass: Search the plane for unmarked tiles */
@ -3125,8 +3127,10 @@ cifSlotsFillArea(
DBPaintPlane(plane, &stripList->area, CIFEraseTable, DBPaintPlane(plane, &stripList->area, CIFEraseTable,
(PaintUndoInfo *) NULL); (PaintUndoInfo *) NULL);
freeMagic(stripList); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, stripList);
stripList = stripList->strip_next; stripList = stripList->strip_next;
freeMagic1_end(&mm1);
} }
/* 2nd pass: Search the plane for unmarked tiles */ /* 2nd pass: Search the plane for unmarked tiles */
@ -4747,9 +4751,6 @@ cifInteractingRegions(
/* Get tile area for interaction search */ /* Get tile area for interaction search */
TiToRect(t, &rect); TiToRect(t, &rect);
/* Ignore tiles outside of the search area */
if (!GEO_SURROUND(area, &rect)) continue;
/* "interacting" includes touching as well as overlapping, so expand /* "interacting" includes touching as well as overlapping, so expand
* search by one unit in every direction and then check overlap. * search by one unit in every direction and then check overlap.
* NOTE: This catches catecorner-touching material, which is * NOTE: This catches catecorner-touching material, which is

View File

@ -851,9 +851,11 @@ CIFPaintCurrent(
freeMagic(propstr); freeMagic(propstr);
} }
propstr = newstr; propstr = newstr;
freeMagic(lrec); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, lrec);
lrec = lrec->r_next; lrec = lrec->r_next;
} freeMagic1_end(&mm1);
}
/* NOTE: propstr is transferred to the CellDef and should /* NOTE: propstr is transferred to the CellDef and should
* not be free'd here. * not be free'd here.
*/ */

View File

@ -338,18 +338,20 @@ CIFPaintWirePath(
pathp = pathheadp->cifp_next; pathp = pathheadp->cifp_next;
if (pathp != NULL) if (pathp != NULL)
{ {
free_magic1_t mm1 = freeMagic1_init();
while (pathp->cifp_next != NULL) while (pathp->cifp_next != NULL)
{ {
if (pathp->cifp_next->cifp_x == pathp->cifp_x && if (pathp->cifp_next->cifp_x == pathp->cifp_x &&
pathp->cifp_next->cifp_y == pathp->cifp_y) pathp->cifp_next->cifp_y == pathp->cifp_y)
{ {
previousp->cifp_next = pathp->cifp_next; previousp->cifp_next = pathp->cifp_next;
freeMagic(pathp); freeMagic1(&mm1, pathp);
} }
else else
previousp = pathp; previousp = pathp;
pathp = pathp->cifp_next; pathp = pathp->cifp_next;
} }
freeMagic1_end(&mm1);
} }
previousp = pathheadp; previousp = pathheadp;
@ -486,11 +488,13 @@ CIFPaintWirePath(
rectp = CIFPolyToRects(polypath, plane, ptable, ui, FALSE); rectp = CIFPolyToRects(polypath, plane, ptable, ui, FALSE);
CIFFreePath(polypath); CIFFreePath(polypath);
free_magic1_t mm1 = freeMagic1_init();
for (; rectp != NULL ; rectp = rectp->r_next) for (; rectp != NULL ; rectp = rectp->r_next)
{ {
DBPaintPlane(plane, &rectp->r_r, ptable, ui); DBPaintPlane(plane, &rectp->r_r, ptable, ui);
freeMagic((char *) rectp); freeMagic1(&mm1, (char *) rectp);
} }
freeMagic1_end(&mm1);
polypath = NULL; polypath = NULL;
} }
else else
@ -588,11 +592,13 @@ PaintPolygon(
rectlist = CIFPolyToRects(cifpath, plane, ptable, ui, FALSE); rectlist = CIFPolyToRects(cifpath, plane, ptable, ui, FALSE);
CIFFreePath(cifpath); CIFFreePath(cifpath);
free_magic1_t mm1 = freeMagic1_init();
for (rectp = rectlist; rectp != NULL ; rectp = rectp->r_next) for (rectp = rectlist; rectp != NULL ; rectp = rectp->r_next)
{ {
DBPaintPlane(plane, &rectp->r_r, ptable, ui); DBPaintPlane(plane, &rectp->r_r, ptable, ui);
if (!keep) freeMagic((char *) rectp); if (!keep) freeMagic1(&mm1, (char *) rectp);
} }
freeMagic1_end(&mm1);
return (keep) ? rectlist : (LinkedRect *)NULL; return (keep) ? rectlist : (LinkedRect *)NULL;
} }
@ -821,11 +827,13 @@ CIFParsePoly(void)
CIFSkipToSemi(); CIFSkipToSemi();
return FALSE; return FALSE;
} }
free_magic1_t mm1 = freeMagic1_init();
for (; rectp != NULL ; rectp = rectp->r_next) for (; rectp != NULL ; rectp = rectp->r_next)
{ {
DBPaintPlane(cifReadPlane, &rectp->r_r, CIFPaintTable, DBPaintPlane(cifReadPlane, &rectp->r_r, CIFPaintTable,
(PaintUndoInfo *) NULL); (PaintUndoInfo *) NULL);
freeMagic((char *) rectp); freeMagic1(&mm1, (char *) rectp);
} }
freeMagic1_end(&mm1);
return TRUE; return TRUE;
} }

View File

@ -329,8 +329,10 @@ cifNewReadStyle(void)
layer = cifCurReadStyle->crs_layers[i]; layer = cifCurReadStyle->crs_layers[i];
if (layer != NULL) if (layer != NULL)
{ {
free_magic1_t mm1 = freeMagic1_init();
for (op = layer->crl_ops; op != NULL; op = op->co_next) for (op = layer->crl_ops; op != NULL; op = op->co_next)
freeMagic((char *)op); freeMagic1(&mm1, (char *)op);
freeMagic1_end(&mm1);
freeMagic((char *)layer); freeMagic((char *)layer);
} }
} }
@ -408,11 +410,13 @@ CIFReadTechInit(void)
/* forget the list of styles */ /* forget the list of styles */
free_magic1_t mm1 = freeMagic1_init();
for (style = cifReadStyleList; style != NULL; style = style->crs_next) for (style = cifReadStyleList; style != NULL; style = style->crs_next)
{ {
freeMagic(style->crs_name); freeMagic(style->crs_name);
freeMagic(style); freeMagic1(&mm1, style);
} }
freeMagic1_end(&mm1);
cifReadStyleList = NULL; cifReadStyleList = NULL;
} }

View File

@ -1338,11 +1338,13 @@ void
CIFFreePath( CIFFreePath(
CIFPath *path) /* Path to be freed. */ CIFPath *path) /* Path to be freed. */
{ {
free_magic1_t mm1 = freeMagic1_init();
while (path != NULL) while (path != NULL)
{ {
freeMagic((char *) path); freeMagic1(&mm1, (char *) path);
path = path->cifp_next; path = path->cifp_next;
} }
freeMagic1_end(&mm1);
} }
/* /*

View File

@ -100,6 +100,7 @@ cifTechFreeStyle(void)
layer = CIFCurStyle->cs_layers[i]; layer = CIFCurStyle->cs_layers[i];
if (layer != NULL) if (layer != NULL)
{ {
free_magic1_t mm1 = freeMagic1_init();
for (op = layer->cl_ops; op != NULL; op = op->co_next) for (op = layer->cl_ops; op != NULL; op = op->co_next)
{ {
if (op->co_client != (ClientData)NULL) if (op->co_client != (ClientData)NULL)
@ -120,8 +121,9 @@ cifTechFreeStyle(void)
break; break;
} }
} }
freeMagic((char *)op); freeMagic1(&mm1, (char *)op);
} }
freeMagic1_end(&mm1);
freeMagic((char *)layer); freeMagic((char *)layer);
} }
} }
@ -388,11 +390,13 @@ CIFTechInit(void)
/* forget the list of styles */ /* forget the list of styles */
free_magic1_t mm1 = freeMagic1_init();
for (style = CIFStyleList; style != NULL; style = style->cs_next) for (style = CIFStyleList; style != NULL; style = style->cs_next)
{ {
freeMagic(style->cs_name); freeMagic(style->cs_name);
freeMagic(style); freeMagic1(&mm1, style);
} }
freeMagic1_end(&mm1);
CIFStyleList = NULL; CIFStyleList = NULL;
} }

View File

@ -530,11 +530,15 @@ badusage:
} }
freelist: freelist:
la = lahead;
while (la != NULL)
{ {
freeMagic((char *)la); la = lahead;
la = la->ar_next; while (la != NULL)
{
free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, (char *)la);
la = la->ar_next;
freeMagic1_end(&mm1);
}
} }
return; return;
} }

View File

@ -2455,6 +2455,7 @@ CmdContact(
rmask = DBResidueMask(type); rmask = DBResidueMask(type);
free_magic1_t mm1 = freeMagic1_init();
while (lr != NULL) while (lr != NULL)
{ {
GeoClip(&lr->r_r, &area); GeoClip(&lr->r_r, &area);
@ -2465,9 +2466,10 @@ CmdContact(
if (TTMaskHasType(rmask, rtype)) if (TTMaskHasType(rmask, rtype))
DBPaint(EditCellUse->cu_def, &lr->r_r, rtype); DBPaint(EditCellUse->cu_def, &lr->r_r, rtype);
freeMagic(lr); freeMagic1(&mm1, lr);
lr = lr->r_next; lr = lr->r_next;
} }
freeMagic1_end(&mm1);
/* Refresh the layout drawing */ /* Refresh the layout drawing */
DBWAreaChanged(EditCellUse->cu_def, &area, DBW_ALLWINDOWS, &smask); DBWAreaChanged(EditCellUse->cu_def, &area, DBW_ALLWINDOWS, &smask);
@ -2504,14 +2506,16 @@ CmdContact(
DBSrPaintArea((Tile *) NULL, EditCellUse->cu_def->cd_planes[DBPlane(rtype)], DBSrPaintArea((Tile *) NULL, EditCellUse->cu_def->cd_planes[DBPlane(rtype)],
&area, &smask, cmdContactFunc, (ClientData) &ccs); &area, &smask, cmdContactFunc, (ClientData) &ccs);
free_magic1_t mm1 = freeMagic1_init();
while (ccs.lhead != NULL) while (ccs.lhead != NULL)
{ {
TTMaskSetOnlyType(&smask, type); TTMaskSetOnlyType(&smask, type);
TTMaskAndMask(&smask, &DBActiveLayerBits); TTMaskAndMask(&smask, &DBActiveLayerBits);
DBPaintMask(EditCellUse->cu_def, &ccs.lhead->r_r, &smask); DBPaintMask(EditCellUse->cu_def, &ccs.lhead->r_r, &smask);
freeMagic(ccs.lhead); freeMagic1(&mm1, ccs.lhead);
ccs.lhead = ccs.lhead->r_next; ccs.lhead = ccs.lhead->r_next;
} }
freeMagic1_end(&mm1);
/* Refresh the layout drawing */ /* Refresh the layout drawing */
DBWAreaChanged(EditCellUse->cu_def, &area, DBW_ALLWINDOWS, &smask); DBWAreaChanged(EditCellUse->cu_def, &area, DBW_ALLWINDOWS, &smask);
@ -2952,14 +2956,22 @@ CmdCorner(
rectp = CIFPolyToRects(cmdPathList.pathlist->pathhead, plane, rectp = CIFPolyToRects(cmdPathList.pathlist->pathhead, plane,
resultTbl, &ui, FALSE); resultTbl, &ui, FALSE);
for (; rectp != NULL; rectp = rectp->r_next)
{ {
DBPaintPlane(plane, &rectp->r_r, resultTbl, &ui); free_magic1_t mm1 = freeMagic1_init();
freeMagic((char *)rectp); for (; rectp != NULL; rectp = rectp->r_next)
{
DBPaintPlane(plane, &rectp->r_r, resultTbl, &ui);
freeMagic1(&mm1, (char *)rectp);
}
freeMagic1_end(&mm1);
} }
CIFFreePath(cmdPathList.pathlist->pathhead); CIFFreePath(cmdPathList.pathlist->pathhead);
freeMagic((char *)cmdPathList.pathlist); {
cmdPathList.pathlist = cmdPathList.pathlist->cpl_next; free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, (char *)cmdPathList.pathlist);
cmdPathList.pathlist = cmdPathList.pathlist->cpl_next;
freeMagic1_end(&mm1);
}
} }
} }
else else
@ -2977,14 +2989,16 @@ CmdCorner(
/* Now that we've got all the material, scan over the list /* Now that we've got all the material, scan over the list
* painting the material and freeing up the entries on the list. * painting the material and freeing up the entries on the list.
*/ */
free_magic1_t mm1 = freeMagic1_init();
while (cmdCornerList != NULL) while (cmdCornerList != NULL)
{ {
DBPaint(EditCellUse->cu_def, &cmdCornerList->cca_area, DBPaint(EditCellUse->cu_def, &cmdCornerList->cca_area,
cmdCornerList->cca_type); cmdCornerList->cca_type);
freeMagic((char *) cmdCornerList); freeMagic1(&mm1, (char *) cmdCornerList);
cmdCornerList = cmdCornerList->cca_next; cmdCornerList = cmdCornerList->cca_next;
} }
} freeMagic1_end(&mm1);
}
SelectClear(); SelectClear();
DBAdjustLabels(EditCellUse->cu_def, &editBox); DBAdjustLabels(EditCellUse->cu_def, &editBox);
@ -3643,8 +3657,10 @@ cmdBevelFunc(
GeoClip(&r3, &cmdCornerRootBox); GeoClip(&r3, &cmdCornerRootBox);
if (GEO_RECTNULL(&r2) || GEO_RECTNULL(&r3)) if (GEO_RECTNULL(&r2) || GEO_RECTNULL(&r3))
{ {
free_magic1_t mm1 = freeMagic1_init();
for (pptr = pathhead; pptr != NULL; pptr = pptr->cifp_next) for (pptr = pathhead; pptr != NULL; pptr = pptr->cifp_next)
freeMagic((char *)pptr); freeMagic1(&mm1, (char *)pptr);
freeMagic1_end(&mm1);
return 0; return 0;
} }
@ -4154,6 +4170,7 @@ CmdDrc(
rootUse = (CellUse *) window->w_surfaceID; rootUse = (CellUse *) window->w_surfaceID;
dcl = DRCCount(rootUse, &rootArea, doforall); dcl = DRCCount(rootUse, &rootArea, doforall);
free_magic1_t mm1 = freeMagic1_init();
while (dcl != NULL) while (dcl != NULL)
{ {
if (count_total >= 0) if (count_total >= 0)
@ -4183,9 +4200,10 @@ CmdDrc(
} }
#endif #endif
} }
freeMagic((char *)dcl); freeMagic1(&mm1, (char *)dcl);
dcl = dcl->dcl_next; dcl = dcl->dcl_next;
} }
freeMagic1_end(&mm1);
#ifdef MAGIC_WRAPPER #ifdef MAGIC_WRAPPER
if ((count_total >= 0) || (!dolist)) if ((count_total >= 0) || (!dolist))
@ -4308,6 +4326,8 @@ CmdDrc(
#endif #endif
TxPrintf("Error area #%d:\n", result); TxPrintf("Error area #%d:\n", result);
if (DRCWhy(dolist, rootUse, &area, findonly)) break; if (DRCWhy(dolist, rootUse, &area, findonly)) break;
/* Check for interrupt or this will go into an infinite loop */
else if (SigInterruptPending) break;
drc_nth++; drc_nth++;
} }
else if (result < 0) else if (result < 0)
@ -4334,12 +4354,14 @@ CmdDrc(
} }
if (findonly) if (findonly)
{ {
free_magic1_t mm1 = freeMagic1_init();
/* Delete temporary rules */ /* Delete temporary rules */
while (DRCIgnoreRules != NULL) while (DRCIgnoreRules != NULL)
{ {
freeMagic(DRCIgnoreRules); freeMagic1(&mm1, DRCIgnoreRules);
DRCIgnoreRules = DRCIgnoreRules->li_next; DRCIgnoreRules = DRCIgnoreRules->li_next;
} }
freeMagic1_end(&mm1);
/* Replace temporary set of rules */ /* Replace temporary set of rules */
DRCIgnoreRules = DRCSaveRules; DRCIgnoreRules = DRCSaveRules;
} }
@ -4422,8 +4444,10 @@ CmdDrc(
{ {
while (DRCIgnoreRules != NULL) while (DRCIgnoreRules != NULL)
{ {
freeMagic(DRCIgnoreRules); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, DRCIgnoreRules);
DRCIgnoreRules = DRCIgnoreRules->li_next; DRCIgnoreRules = DRCIgnoreRules->li_next;
freeMagic1_end(&mm1);
} }
} }
else else

View File

@ -581,13 +581,15 @@ CmdFill(
/* Now that we've got all the material, scan over the list /* Now that we've got all the material, scan over the list
* painting the material and freeing up the entries on the list. * painting the material and freeing up the entries on the list.
*/ */
free_magic1_t mm1 = freeMagic1_init();
while (cmdFillList != NULL) while (cmdFillList != NULL)
{ {
DBPaint(EditCellUse->cu_def, &cmdFillList->cfa_area, DBPaint(EditCellUse->cu_def, &cmdFillList->cfa_area,
cmdFillList->cfa_type); cmdFillList->cfa_type);
freeMagic((char *) cmdFillList); freeMagic1(&mm1, (char *) cmdFillList);
cmdFillList = cmdFillList->cfa_next; cmdFillList = cmdFillList->cfa_next;
} }
freeMagic1_end(&mm1);
SelectClear(); SelectClear();
DBAdjustLabels(EditCellUse->cu_def, &editBox); DBAdjustLabels(EditCellUse->cu_def, &editBox);

View File

@ -1256,15 +1256,17 @@ CmdSelect(
/* of rlist) */ /* of rlist) */
SelectClear(); SelectClear();
free_magic1_t mm1 = freeMagic1_init();
while (rlist != NULL) while (rlist != NULL)
{ {
/* Paint rlist back into SelectDef */ /* Paint rlist back into SelectDef */
DBPaint(SelectDef, &rlist->r_r, rlist->r_type); DBPaint(SelectDef, &rlist->r_r, rlist->r_type);
/* cleanup as we go */ /* cleanup as we go */
freeMagic(rlist); freeMagic1(&mm1, rlist);
rlist = rlist->r_next; rlist = rlist->r_next;
} }
freeMagic1_end(&mm1);
/* Force erase and redraw of the selection */ /* Force erase and redraw of the selection */
DBReComputeBbox(SelectDef); DBReComputeBbox(SelectDef);

View File

@ -1103,11 +1103,13 @@ CmdWhat(
} }
#endif #endif
while (lid != NULL) free_magic1_t mm1 = freeMagic1_init();
{ while (lid != NULL)
freeMagic(lid); {
freeMagic1(&mm1, lid);
lid = lid->lid_next; lid = lid->lid_next;
} }
freeMagic1_end(&mm1);
#ifdef MAGIC_WRAPPER #ifdef MAGIC_WRAPPER
if (doListAll) if (doListAll)
Tcl_ListObjAppendElement(magicinterp, paintobj, Tcl_ListObjAppendElement(magicinterp, paintobj,

View File

@ -108,25 +108,55 @@ DBCellFindDup(use, parent)
"DBCellFindDup"); "DBCellFindDup");
while ((dupUse = BPEnumNext(&bpe))) while ((dupUse = BPEnumNext(&bpe)))
if (dupUse->cu_def == use->cu_def) if (dupUse->cu_def == use->cu_def)
{
bool transMatch, arrayMatch, notXarray, notYarray;
/* Transforms must be equal---Aligned bounding boxes are /* Transforms must be equal---Aligned bounding boxes are
* an insufficient measure of exact overlap. Also, array * an insufficient measure of exact overlap. Also, array
* counts and separation must match for arrayed devices * counts and separation must match for arrayed devices
*/ */
if ((dupUse->cu_transform.t_a == use->cu_transform.t_a) && transMatch = ((dupUse->cu_transform.t_a == use->cu_transform.t_a) &&
(dupUse->cu_transform.t_b == use->cu_transform.t_b) && (dupUse->cu_transform.t_b == use->cu_transform.t_b) &&
(dupUse->cu_transform.t_c == use->cu_transform.t_c) && (dupUse->cu_transform.t_c == use->cu_transform.t_c) &&
(dupUse->cu_transform.t_d == use->cu_transform.t_d) && (dupUse->cu_transform.t_d == use->cu_transform.t_d) &&
(dupUse->cu_transform.t_e == use->cu_transform.t_e) && (dupUse->cu_transform.t_e == use->cu_transform.t_e) &&
(dupUse->cu_transform.t_f == use->cu_transform.t_f) && (dupUse->cu_transform.t_f == use->cu_transform.t_f));
((dupUse->cu_xhi > dupUse->cu_xlo) &&
((dupUse->cu_xhi - dupUse->cu_xlo) == /* First check if both use and dupUse are not arrays. */
notXarray = (dupUse->cu_xhi == dupUse->cu_xlo) &&
(use->cu_xhi == use->cu_xlo);
notYarray = (dupUse->cu_yhi == dupUse->cu_ylo) &&
(use->cu_yhi == use->cu_ylo);
arrayMatch = (notXarray && notYarray);
/* If they are arrays, then the array parameters must match. */
if (!notXarray && notYarray)
{
arrayMatch = ((dupUse->cu_xhi - dupUse->cu_xlo) ==
(use->cu_xhi - use->cu_xlo)) &&
(dupUse->cu_xsep == use->cu_xsep);
}
else if (!notYarray && notXarray)
{
arrayMatch = ((dupUse->cu_yhi - dupUse->cu_ylo) ==
(use->cu_yhi - use->cu_ylo)) &&
(dupUse->cu_ysep == use->cu_ysep);
}
else if (!notYarray && !notXarray)
{
arrayMatch = (((dupUse->cu_xhi - dupUse->cu_xlo) ==
(use->cu_xhi - use->cu_xlo)) && (use->cu_xhi - use->cu_xlo)) &&
(dupUse->cu_xsep == use->cu_xsep)) && (dupUse->cu_xsep == use->cu_xsep)) &&
((dupUse->cu_yhi > dupUse->cu_ylo) && (((dupUse->cu_yhi - dupUse->cu_ylo) ==
((dupUse->cu_yhi - dupUse->cu_ylo) ==
(use->cu_yhi - use->cu_ylo)) && (use->cu_yhi - use->cu_ylo)) &&
(dupUse->cu_ysep == use->cu_ysep))) (dupUse->cu_ysep == use->cu_ysep));
}
if (transMatch && arrayMatch)
break; break;
}
BPEnumTerm(&bpe); BPEnumTerm(&bpe);
return dupUse; return dupUse;

View File

@ -320,6 +320,7 @@ DBCellDelete(cellname, force)
/* use. If so, load the window with (UNNAMED). */ /* use. If so, load the window with (UNNAMED). */
UndoDisable(); UndoDisable();
free_magic1_t mm1 = freeMagic1_init();
for (celluse = celldef->cd_parents; celluse != (CellUse *) NULL; for (celluse = celldef->cd_parents; celluse != (CellUse *) NULL;
celluse = celluse->cu_nextuse) celluse = celluse->cu_nextuse)
{ {
@ -328,8 +329,9 @@ DBCellDelete(cellname, force)
WindUnload(celluse); WindUnload(celluse);
freeMagic(celluse->cu_id); freeMagic(celluse->cu_id);
} }
freeMagic((char *)celluse); freeMagic1(&mm1, (char *)celluse);
} }
freeMagic1_end(&mm1);
celldef->cd_parents = (CellUse *)NULL; celldef->cd_parents = (CellUse *)NULL;
DBWResetBox(celldef); DBWResetBox(celldef);
@ -2006,8 +2008,10 @@ DBCellDefFree(cellDef)
cellDef->cd_planes[pNum] = (Plane *) NULL; cellDef->cd_planes[pNum] = (Plane *) NULL;
} }
free_magic1_t mm1 = freeMagic1_init();
for (lab = cellDef->cd_labels; lab; lab = lab->lab_next) for (lab = cellDef->cd_labels; lab; lab = lab->lab_next)
freeMagic((char *) lab); freeMagic1(&mm1, (char *) lab);
freeMagic1_end(&mm1);
SigEnableInterrupts(); SigEnableInterrupts();
HashKill(&cellDef->cd_idHash); HashKill(&cellDef->cd_idHash);

View File

@ -1516,13 +1516,14 @@ DBScaleEverything(scalen, scaled)
} }
/* Free the linked CellDef list */ /* Free the linked CellDef list */
free_magic1_t mm1 = freeMagic1_init();
lcd = lhead; lcd = lhead;
while (lcd != NULL) while (lcd != NULL)
{ {
freeMagic((char *)lcd); freeMagic1(&mm1, (char *)lcd);
lcd = lcd->cd_next; lcd = lcd->cd_next;
} }
freeMagic1_end(&mm1);
/* Scale all elements */ /* Scale all elements */
DBWScaleElements(scalen, scaled); DBWScaleElements(scalen, scaled);
@ -1769,12 +1770,14 @@ DBSrCellUses(cellDef, func, arg)
} }
/* Free this linked cellUse structure */ /* Free this linked cellUse structure */
free_magic1_t mm1 = freeMagic1_init();
lu = luhead; lu = luhead;
while (lu != NULL) while (lu != NULL)
{ {
freeMagic((char *)lu); freeMagic1(&mm1, (char *)lu);
lu = lu->cu_next; lu = lu->cu_next;
} }
freeMagic1_end(&mm1);
return retval; return retval;
} }
@ -2002,12 +2005,14 @@ dbScaleCell(cellDef, scalen, scaled)
BPFree(cellPlaneOrig); BPFree(cellPlaneOrig);
/* Free this linked cellUse structure */ /* Free this linked cellUse structure */
free_magic1_t mm1 = freeMagic1_init();
lu = luhead; lu = luhead;
while (lu != NULL) while (lu != NULL)
{ {
freeMagic((char *)lu); freeMagic1(&mm1, (char *)lu);
lu = lu->cu_next; lu = lu->cu_next;
} }
freeMagic1_end(&mm1);
/* Scale all of the paint tiles in this cell by creating a new plane */ /* Scale all of the paint tiles in this cell by creating a new plane */
/* and copying all tiles into the new plane at scaled dimensions. */ /* and copying all tiles into the new plane at scaled dimensions. */
@ -2210,12 +2215,14 @@ DBMoveCell(cellDef, origx, origy)
BPFree(cellPlaneOrig); BPFree(cellPlaneOrig);
/* Free this linked cellUse structure */ /* Free this linked cellUse structure */
free_magic1_t mm1 = freeMagic1_init();
lu = luhead; lu = luhead;
while (lu != NULL) while (lu != NULL)
{ {
freeMagic((char *)lu); freeMagic1(&mm1, (char *)lu);
lu = lu->cu_next; lu = lu->cu_next;
} }
freeMagic1_end(&mm1);
/* Move all of the paint tiles in this cell by creating a new plane */ /* Move all of the paint tiles in this cell by creating a new plane */
/* and copying all tiles into the new plane at the new position. */ /* and copying all tiles into the new plane at the new position. */

View File

@ -218,8 +218,10 @@ DBCellClearDef(cellDef)
cellDef->cd_bbox.r_xtop = cellDef->cd_bbox.r_ytop = 1; cellDef->cd_bbox.r_xtop = cellDef->cd_bbox.r_ytop = 1;
cellDef->cd_extended.r_xbot = cellDef->cd_extended.r_ybot = 0; cellDef->cd_extended.r_xbot = cellDef->cd_extended.r_ybot = 0;
cellDef->cd_extended.r_xtop = cellDef->cd_extended.r_ytop = 1; cellDef->cd_extended.r_xtop = cellDef->cd_extended.r_ytop = 1;
free_magic1_t mm1 = freeMagic1_init();
for (lab = cellDef->cd_labels; lab; lab = lab->lab_next) for (lab = cellDef->cd_labels; lab; lab = lab->lab_next)
freeMagic((char *) lab); freeMagic1(&mm1, (char *) lab);
freeMagic1_end(&mm1);
cellDef->cd_labels = (Label *) NULL; cellDef->cd_labels = (Label *) NULL;
cellDef->cd_lastLabel = (Label *) NULL; cellDef->cd_lastLabel = (Label *) NULL;

View File

@ -828,6 +828,7 @@ dbcConnectLabelFunc(scx, lab, tpath, csa2)
CellDef *orig_def = scx->scx_use->cu_def; CellDef *orig_def = scx->scx_use->cu_def;
Label *slab; Label *slab;
int lidx = lab->lab_port; int lidx = lab->lab_port;
bool foundOne;
const TileTypeBitMask *connectMask; const TileTypeBitMask *connectMask;
/* Check for equivalent ports. For any found, call */ /* Check for equivalent ports. For any found, call */
@ -839,6 +840,7 @@ dbcConnectLabelFunc(scx, lab, tpath, csa2)
/* are more equivalent ports, they will be found when */ /* are more equivalent ports, they will be found when */
/* processing this label's area. */ /* processing this label's area. */
foundOne = FALSE;
for (slab = orig_def->cd_labels; slab != NULL; slab = slab->lab_next) for (slab = orig_def->cd_labels; slab != NULL; slab = slab->lab_next)
if ((slab->lab_flags & PORT_DIR_MASK) && (slab != lab)) if ((slab->lab_flags & PORT_DIR_MASK) && (slab != lab))
if (slab->lab_port == lidx) if (slab->lab_port == lidx)
@ -899,6 +901,20 @@ dbcConnectLabelFunc(scx, lab, tpath, csa2)
csa2->csa2_list[csa2->csa2_top].connectMask = connectMask; csa2->csa2_list[csa2->csa2_top].connectMask = connectMask;
csa2->csa2_list[csa2->csa2_top].dinfo = 0; csa2->csa2_list[csa2->csa2_top].dinfo = 0;
#if 0
/* This warning is useful but currently is generating
* multiple messages per instance and so its more of
* an annoyance than an aid.
*/
if (foundOne == FALSE)
TxError("Warning: Port %s at location (%d %d) connects"
" a net across multiple disconnected areas!\n",
lab->lab_text, lab->lab_rect.r_xbot,
lab->lab_rect.r_ybot);
#endif
foundOne = TRUE;
/* See above: Process only one equivalent port at a time */ /* See above: Process only one equivalent port at a time */
break; break;
} }
@ -1247,7 +1263,8 @@ DBTreeCopyConnect(scx, mask, xMask, connect, area, doLabels, destUse)
if (DBTreeSrLabels(scx, newmask, xMask, &tpath, searchtype, if (DBTreeSrLabels(scx, newmask, xMask, &tpath, searchtype,
dbcConnectLabelFunc, (ClientData) &csa2) != 0) dbcConnectLabelFunc, (ClientData) &csa2) != 0)
{ {
TxError("Connection search hit memory limit and stopped.\n"); TxError("Connection search was interrupted or hit "
"memory limit and stopped.\n");
break; break;
} }
} }

View File

@ -98,6 +98,9 @@ extern bool FileLocking;
/* Suffix for all Magic files */ /* Suffix for all Magic files */
char *DBSuffix = ".mag"; char *DBSuffix = ".mag";
#ifdef HAVE_ZLIB
char *DBZSuffix = ".mag.gz";
#endif
/* Magic units per lambda (2 integers, representing (n / d) */ /* Magic units per lambda (2 integers, representing (n / d) */
int DBLambda[2] = {1, 1}; int DBLambda[2] = {1, 1};
@ -280,8 +283,10 @@ DBSearchForTech(techname, techroot, pathroot, level)
if (!strcmp(tdent->d_name, techname)) if (!strcmp(tdent->d_name, techname))
{ {
closedir(tdir); closedir(tdir);
free_magic1_t mm1 = freeMagic1_init();
for (ld = dlist; ld; ld = ld->ld_next) for (ld = dlist; ld; ld = ld->ld_next)
freeMagic(ld); freeMagic1(&mm1, ld);
freeMagic1_end(&mm1);
return pathroot; return pathroot;
} }
} }
@ -294,8 +299,10 @@ DBSearchForTech(techname, techroot, pathroot, level)
if (found) if (found)
{ {
closedir(tdir); closedir(tdir);
free_magic1_t mm1 = freeMagic1_init();
for (ld = dlist; ld; ld = ld->ld_next) for (ld = dlist; ld; ld = ld->ld_next)
freeMagic(ld); freeMagic1(&mm1, ld);
freeMagic1_end(&mm1);
return found; return found;
} }
} }
@ -303,8 +310,12 @@ DBSearchForTech(techname, techroot, pathroot, level)
closedir(tdir); closedir(tdir);
} }
for (ld = dlist; ld; ld = ld->ld_next) {
freeMagic(ld); free_magic1_t mm1 = freeMagic1_init();
for (ld = dlist; ld; ld = ld->ld_next)
freeMagic1(&mm1, ld);
freeMagic1_end(&mm1);
}
return NULL; return NULL;
} }
@ -1483,15 +1494,28 @@ dbReadOpen(cellDef, setFileName, dereference, errptr)
/* If dereferencing, then use search paths first */ /* If dereferencing, then use search paths first */
if (!dereference) if (!dereference)
{
f = PaLockZOpen(cellDef->cd_file, "r", DBSuffix, ".", f = PaLockZOpen(cellDef->cd_file, "r", DBSuffix, ".",
(char *) NULL, &filename, &is_locked, &fd); (char *) NULL, &filename, &is_locked, &fd);
#ifdef HAVE_ZLIB
if (f == NULL)
f = PaLockZOpen(cellDef->cd_file, "r", DBZSuffix, ".",
(char *) NULL, &filename, &is_locked, &fd);
#endif
}
/* Fall back on the original method of using search paths. */ /* Fall back on the original method of using search paths. */
if (f == NULL) if (f == NULL)
{ {
f = PaLockZOpen(cellDef->cd_name, "r", DBSuffix, Path, f = PaLockZOpen(cellDef->cd_name, "r", DBSuffix, Path,
CellLibPath, &filename, &is_locked, &fd); CellLibPath, &filename, &is_locked, &fd);
#ifdef HAVE_ZLIB
if (f == NULL)
f = PaLockZOpen(cellDef->cd_file, "r", DBZSuffix, Path,
CellLibPath, &filename, &is_locked, &fd);
#endif
if (f != NULL) if (f != NULL)
{ {
@ -1524,6 +1548,11 @@ dbReadOpen(cellDef, setFileName, dereference, errptr)
{ {
f = PaLockZOpen(cellDef->cd_file, "r", DBSuffix, ".", f = PaLockZOpen(cellDef->cd_file, "r", DBSuffix, ".",
(char *) NULL, &filename, &is_locked, &fd); (char *) NULL, &filename, &is_locked, &fd);
#ifdef HAVE_ZLIB
if (f == NULL)
f = PaLockZOpen(cellDef->cd_file, "r", DBZSuffix, ".",
(char *) NULL, &filename, &is_locked, &fd);
#endif
if (f != NULL) if (f != NULL)
if (DBVerbose) if (DBVerbose)
TxError("Warning: Dereferenced cell \"%s\" not " TxError("Warning: Dereferenced cell \"%s\" not "
@ -1541,6 +1570,11 @@ dbReadOpen(cellDef, setFileName, dereference, errptr)
{ {
f = PaLockZOpen(cellDef->cd_name, "r", DBSuffix, Path, f = PaLockZOpen(cellDef->cd_name, "r", DBSuffix, Path,
CellLibPath, &filename, &is_locked, &fd); CellLibPath, &filename, &is_locked, &fd);
#ifdef HAVE_ZLIB
if (f == NULL)
f = PaLockZOpen(cellDef->cd_name, "r", DBZSuffix, Path,
CellLibPath, &filename, &is_locked, &fd);
#endif
if (errptr != NULL) *errptr = errno; if (errptr != NULL) *errptr = errno;
} }
@ -3292,7 +3326,8 @@ dbFindPropGCFFunc(key, value, ggcf)
break; break;
else if (numvals != 4) else if (numvals != 4)
{ {
TxError("Error: Cannot parse %s property value!\n", key); TxError("Error: Cannot parse %s property value at \"%s\"!\n",
key, vptr);
break; break;
} }
else else
@ -3311,7 +3346,7 @@ dbFindPropGCFFunc(key, value, ggcf)
/* Skip forward four values in value */ /* Skip forward four values in value */
for (n = 0; n < 4; n++) for (n = 0; n < 4; n++)
{ {
while (!isspace(*vptr)) vptr++; while (!isspace(*vptr) && (*vptr != '\0')) vptr++;
while (isspace(*vptr) && (*vptr != '\0')) vptr++; while (isspace(*vptr) && (*vptr != '\0')) vptr++;
} }
} }

View File

@ -280,6 +280,7 @@ DBEraseGlobLabel(cellDef, area, mask, areaReturn, globmatch)
bool erasedAny = FALSE; bool erasedAny = FALSE;
TileType newType; TileType newType;
free_magic1_t mm1 = freeMagic1_init();
labPrev = NULL; labPrev = NULL;
lab = cellDef->cd_labels; lab = cellDef->cd_labels;
while (lab != NULL) while (lab != NULL)
@ -313,7 +314,7 @@ DBEraseGlobLabel(cellDef, area, mask, areaReturn, globmatch)
if ((lab->lab_font >= 0) && areaReturn) if ((lab->lab_font >= 0) && areaReturn)
GeoInclude(&lab->lab_bbox, areaReturn); GeoInclude(&lab->lab_bbox, areaReturn);
freeMagic((char *) lab); freeMagic1(&mm1, (char *) lab);
lab = lab->lab_next; lab = lab->lab_next;
erasedAny = TRUE; erasedAny = TRUE;
continue; continue;
@ -321,6 +322,7 @@ DBEraseGlobLabel(cellDef, area, mask, areaReturn, globmatch)
nextLab: labPrev = lab; nextLab: labPrev = lab;
lab = lab->lab_next; lab = lab->lab_next;
} }
freeMagic1_end(&mm1);
if (erasedAny) if (erasedAny)
cellDef->cd_flags |= CDMODIFIED|CDGETNEWSTAMP; cellDef->cd_flags |= CDMODIFIED|CDGETNEWSTAMP;
@ -442,6 +444,7 @@ DBEraseLabelsByContent(def, rect, type, text)
{ {
Label *lab, *labPrev; Label *lab, *labPrev;
free_magic1_t mm1 = freeMagic1_init();
for (labPrev = NULL, lab = def->cd_labels; for (labPrev = NULL, lab = def->cd_labels;
lab != NULL; lab != NULL;
labPrev = lab, lab = lab->lab_next) labPrev = lab, lab = lab->lab_next)
@ -457,7 +460,7 @@ DBEraseLabelsByContent(def, rect, type, text)
else labPrev->lab_next = lab->lab_next; else labPrev->lab_next = lab->lab_next;
if (def->cd_lastLabel == lab) if (def->cd_lastLabel == lab)
def->cd_lastLabel = labPrev; def->cd_lastLabel = labPrev;
freeMagic((char *) lab); freeMagic1(&mm1, (char *) lab);
/* Don't iterate through loop, since this will skip a label: /* Don't iterate through loop, since this will skip a label:
* just go back to top. This is tricky! * just go back to top. This is tricky!
@ -467,6 +470,7 @@ DBEraseLabelsByContent(def, rect, type, text)
if (lab == NULL) break; if (lab == NULL) break;
else goto nextCheck; else goto nextCheck;
} }
freeMagic1_end(&mm1);
} }
/* /*
@ -495,6 +499,7 @@ DBRemoveLabel(def, refLab)
{ {
Label *lab, *labPrev; Label *lab, *labPrev;
free_magic1_t mm1 = freeMagic1_init();
for (labPrev = NULL, lab = def->cd_labels; for (labPrev = NULL, lab = def->cd_labels;
lab != NULL; lab != NULL;
labPrev = lab, lab = lab->lab_next) labPrev = lab, lab = lab->lab_next)
@ -508,7 +513,7 @@ DBRemoveLabel(def, refLab)
else labPrev->lab_next = lab->lab_next; else labPrev->lab_next = lab->lab_next;
if (def->cd_lastLabel == lab) if (def->cd_lastLabel == lab)
def->cd_lastLabel = labPrev; def->cd_lastLabel = labPrev;
freeMagic((char *) lab); freeMagic1(&mm1, (char *) lab);
/* Don't iterate through loop, since this will skip a label: /* Don't iterate through loop, since this will skip a label:
* just go back to top. This is tricky! * just go back to top. This is tricky!
@ -518,6 +523,7 @@ DBRemoveLabel(def, refLab)
if (lab == NULL) break; if (lab == NULL) break;
else goto nextCheck; else goto nextCheck;
} }
freeMagic1_end(&mm1);
} }
/* /*
@ -760,8 +766,10 @@ DBAdjustLabelsNew(def, area)
def->cd_lastLabel = labPrev; def->cd_lastLabel = labPrev;
DBUndoEraseLabel(def, lab); DBUndoEraseLabel(def, lab);
DBWLabelChanged(def, lab, DBW_ALLWINDOWS); DBWLabelChanged(def, lab, DBW_ALLWINDOWS);
freeMagic((char *) lab); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, (char *) lab);
lab = lab->lab_next; lab = lab->lab_next;
freeMagic1_end(&mm1);
modified = TRUE; modified = TRUE;
continue; continue;
} }
@ -1744,8 +1752,10 @@ DBLoadFont(fontfile, scale)
} }
/* Remove the pointlist */ /* Remove the pointlist */
free_magic1_t mm1 = freeMagic1_init();
for (newPath = pathStart; newPath != NULL; newPath = newPath->fp_next) for (newPath = pathStart; newPath != NULL; newPath = newPath->fp_next)
freeMagic(newPath); freeMagic1(&mm1, newPath);
freeMagic1_end(&mm1);
pathStart = NULL; pathStart = NULL;
} }
else else

View File

@ -1796,12 +1796,14 @@ nextrect:
lr = lr->r_next; lr = lr->r_next;
} }
free_magic1_t mm1 = freeMagic1_init();
lr = lhead; lr = lhead;
while (lr != NULL) while (lr != NULL)
{ {
freeMagic((char *) lr); freeMagic1(&mm1, (char *) lr);
lr = lr->r_next; lr = lr->r_next;
} }
freeMagic1_end(&mm1);
} }
else else
result = DBPaintPlane0(plane, area, resultTbl, undo, (method == PAINT_MARK) ? result = DBPaintPlane0(plane, area, resultTbl, undo, (method == PAINT_MARK) ?

View File

@ -126,12 +126,14 @@ DBTechInitPlane(void)
{ {
NameList *tbl; NameList *tbl;
free_magic1_t mm1 = freeMagic1_init();
for (tbl = dbPlaneNameLists.sn_next; tbl != &dbPlaneNameLists; for (tbl = dbPlaneNameLists.sn_next; tbl != &dbPlaneNameLists;
tbl = tbl->sn_next) tbl = tbl->sn_next)
{ {
freeMagic(tbl->sn_name); freeMagic(tbl->sn_name);
freeMagic(tbl); freeMagic1(&mm1, tbl);
} }
freeMagic1_end(&mm1);
} }
/* Tables of short names */ /* Tables of short names */
@ -205,12 +207,14 @@ DBTechInitType()
{ {
NameList *tbl; NameList *tbl;
free_magic1_t mm1 = freeMagic1_init();
for (tbl = dbTypeNameLists.sn_next; tbl != &dbTypeNameLists; for (tbl = dbTypeNameLists.sn_next; tbl != &dbTypeNameLists;
tbl = tbl->sn_next) tbl = tbl->sn_next)
{ {
freeMagic(tbl->sn_name); freeMagic(tbl->sn_name);
freeMagic(tbl); freeMagic1(&mm1, tbl);
} }
freeMagic1_end(&mm1);
} }
/* Tables of short names */ /* Tables of short names */

View File

@ -137,8 +137,10 @@ DBFixMismatch()
cellDef = mismatch->mm_cellDef; cellDef = mismatch->mm_cellDef;
oldArea = mismatch->mm_oldArea; oldArea = mismatch->mm_oldArea;
freeMagic((char *) mismatch); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, (char *) mismatch);
mismatch = mismatch->mm_next; mismatch = mismatch->mm_next;
freeMagic1_end(&mm1);
if (cellDef->cd_flags & CDPROCESSED) continue; if (cellDef->cd_flags & CDPROCESSED) continue;
(void) DBCellRead(cellDef, TRUE, TRUE, NULL); (void) DBCellRead(cellDef, TRUE, TRUE, NULL);
@ -182,13 +184,15 @@ DBFixMismatch()
} }
SigEnableInterrupts(); SigEnableInterrupts();
TxPrintf("Timestamp mismatches found in these cells: "); TxPrintf("Timestamp mismatches found in these cells: ");
free_magic1_t mm1 = freeMagic1_init();
while (cl != NULL) while (cl != NULL)
{ {
TxPrintf("%s", cl->cl_cell->cd_name); TxPrintf("%s", cl->cl_cell->cd_name);
if (cl->cl_next != NULL) TxPrintf(", "); if (cl->cl_next != NULL) TxPrintf(", ");
freeMagic(cl); freeMagic1(&mm1, cl);
cl = cl->cl_next; cl = cl->cl_next;
} }
freeMagic1_end(&mm1);
TxPrintf(".\n"); TxPrintf(".\n");
TxFlush(); TxFlush();
if (redisplay) WindAreaChanged((MagWindow *) NULL, (Rect *) NULL); if (redisplay) WindAreaChanged((MagWindow *) NULL, (Rect *) NULL);
@ -227,7 +231,7 @@ DBUpdateStamps(def)
else if (def->cd_flags & CDGETNEWSTAMP) else if (def->cd_flags & CDGETNEWSTAMP)
{ {
if (def->cd_flags & CDFIXEDSTAMP) if (def->cd_flags & (CDNOEDIT | CDFIXEDSTAMP))
def->cd_flags &= ~CDGETNEWSTAMP; def->cd_flags &= ~CDGETNEWSTAMP;
else else
dbStampFunc(def); dbStampFunc(def);
@ -247,6 +251,26 @@ dbStampFunc(cellDef)
if (cellDef->cd_timestamp == timestamp) return 0; if (cellDef->cd_timestamp == timestamp) return 0;
/* Non-editable cells should not try to update timestamps, as the
* new timestamp cannot be written back to the file. This is
* basically a hack solution for the problem that running DRC on
* all cells causes all cells, including non-editable ones, to be
* marked as modified, even if there were no DRC changes in the
* cell. It is possible to get into trouble this way by modifying
* a cell and then marking it as non-editable
*/
if (cellDef->cd_flags & CDNOEDIT)
{
cellDef->cd_flags &= ~CDGETNEWSTAMP;
return 0;
}
/*
* Do not force a non-edit cell or a cell with a fixed timestamp
* to update its timestamp, as it cannot or should not. Just clear
* any flag suggesting that it needs a new timestamp.
*/
if (!(cellDef->cd_flags & CDFIXEDSTAMP)) if (!(cellDef->cd_flags & CDFIXEDSTAMP))
cellDef->cd_timestamp = timestamp; cellDef->cd_timestamp = timestamp;

View File

@ -588,10 +588,12 @@ DBWElementDelete(MagWindow *w, char *name)
if (elem->flags & DBW_ELEMENT_PERSISTENT) if (elem->flags & DBW_ELEMENT_PERSISTENT)
elem->rootDef->cd_flags |= CDMODIFIED; elem->rootDef->cd_flags |= CDMODIFIED;
free_magic1_t mm1 = freeMagic1_init();
for (stylePtr = elem->stylelist; stylePtr != NULL; stylePtr = stylePtr->next) for (stylePtr = elem->stylelist; stylePtr != NULL; stylePtr = stylePtr->next)
{ {
freeMagic(stylePtr); freeMagic1(&mm1, stylePtr);
} }
freeMagic1_end(&mm1);
if (elem->type == ELEMENT_TEXT) if (elem->type == ELEMENT_TEXT)
freeMagic(elem->text); freeMagic(elem->text);
@ -1156,8 +1158,10 @@ DBWElementStyle(MagWindow *w, char *ename, int style, bool add)
(elem->stylelist->style == style)) (elem->stylelist->style == style))
{ {
dbwElementUndraw(w, elem); dbwElementUndraw(w, elem);
freeMagic(elem->stylelist); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, elem->stylelist);
elem->stylelist = elem->stylelist->next; elem->stylelist = elem->stylelist->next;
freeMagic1_end(&mm1);
if (elem->stylelist == NULL) if (elem->stylelist == NULL)
TxPrintf("Warning: Element %s has no styles!\n", ename); TxPrintf("Warning: Element %s has no styles!\n", ename);
} }
@ -1169,8 +1173,10 @@ DBWElementStyle(MagWindow *w, char *ename, int style, bool add)
else if (sptr->next != NULL) else if (sptr->next != NULL)
{ {
dbwElementUndraw(w, elem); dbwElementUndraw(w, elem);
freeMagic(sptr->next); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, sptr->next);
sptr->next = sptr->next->next; sptr->next = sptr->next->next;
freeMagic1_end(&mm1);
} }
} }
/* mark element's cell as having been modified */ /* mark element's cell as having been modified */
@ -1279,8 +1285,10 @@ DBWElementClearDef(cellDef)
if (!elem) continue; if (!elem) continue;
if (elem->rootDef != cellDef) continue; if (elem->rootDef != cellDef) continue;
free_magic1_t mm1 = freeMagic1_init();
for (stylePtr = elem->stylelist; stylePtr != NULL; stylePtr = stylePtr->next) for (stylePtr = elem->stylelist; stylePtr != NULL; stylePtr = stylePtr->next)
freeMagic(stylePtr); freeMagic1(&mm1, stylePtr);
freeMagic1_end(&mm1);
if (elem->type == ELEMENT_TEXT) if (elem->type == ELEMENT_TEXT)
freeMagic(elem->text); freeMagic(elem->text);

View File

@ -547,8 +547,10 @@ DRCContinuous()
if (DRCPendingRoot != (DRCPendingCookie *)NULL) { if (DRCPendingRoot != (DRCPendingCookie *)NULL) {
DBReComputeBbox(DRCPendingRoot->dpc_def); DBReComputeBbox(DRCPendingRoot->dpc_def);
freeMagic((char *) DRCPendingRoot); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, (char *) DRCPendingRoot);
DRCPendingRoot = DRCPendingRoot->dpc_next; DRCPendingRoot = DRCPendingRoot->dpc_next;
freeMagic1_end(&mm1);
} }
/* Give the timestamp manager a chance to update any mismatches. */ /* Give the timestamp manager a chance to update any mismatches. */

View File

@ -522,11 +522,13 @@ DRCTechInit()
drcTechFreeStyle(); drcTechFreeStyle();
free_magic1_t mm1 = freeMagic1_init();
for (style = DRCStyleList; style != NULL; style = style->ds_next) for (style = DRCStyleList; style != NULL; style = style->ds_next)
{ {
freeMagic(style->ds_name); freeMagic(style->ds_name);
freeMagic(style); freeMagic1(&mm1, style);
} }
freeMagic1_end(&mm1);
DRCStyleList = NULL; DRCStyleList = NULL;
} }
@ -4079,6 +4081,7 @@ drcTechFinalStyle(style)
{ {
for (j = 0; j < DBNumTypes; j++) for (j = 0; j < DBNumTypes; j++)
{ {
free_magic1_t mm1 = freeMagic1_init();
for (dp = style->DRCRulesTbl[i][j]; dp != NULL; dp = dp->drcc_next) for (dp = style->DRCRulesTbl[i][j]; dp != NULL; dp = dp->drcc_next)
{ {
/* Don't optimize on trigger rules; optimize on the */ /* Don't optimize on trigger rules; optimize on the */
@ -4161,7 +4164,8 @@ drcTechFinalStyle(style)
if (dptrig != NULL) if (dptrig != NULL)
{ {
dptrig = dp->drcc_next; dptrig = dp->drcc_next;
freeMagic((char *)dp->drcc_next); free_magic1_t mm1_ = freeMagic1_init();
freeMagic1(&mm1_, (char *)dp->drcc_next);
*dp2back = dp->drcc_next->drcc_next; *dp2back = dp->drcc_next->drcc_next;
/* Replace this entry so on the next cycle */ /* Replace this entry so on the next cycle */
@ -4169,13 +4173,15 @@ drcTechFinalStyle(style)
/* even though dp is free'd (below), due to */ /* even though dp is free'd (below), due to */
/* the one-delayed free mechanism. */ /* the one-delayed free mechanism. */
dp->drcc_next = *dp2back; dp->drcc_next = *dp2back;
freeMagic1_end(&mm1_);
} }
else else
*dp2back = dp->drcc_next; *dp2back = dp->drcc_next;
freeMagic((char *) dp); freeMagic1(&mm1, (char *) dp);
drcRulesOptimized += 1; drcRulesOptimized += 1;
} }
freeMagic1_end(&mm1);
} }
} }
} }

View File

@ -683,8 +683,10 @@ runexttosim:
EFVisitDevs(simmergeVisit, PTR2CD(NULL)); EFVisitDevs(simmergeVisit, PTR2CD(NULL));
TxPrintf("Devices merged: %d\n", esDevsMerged); TxPrintf("Devices merged: %d\n", esDevsMerged);
esFMIndex = 0; esFMIndex = 0;
free_magic1_t mm1 = freeMagic1_init();
for (p = devMergeList; p != NULL; p = p->next) for (p = devMergeList; p != NULL; p = p->next)
freeMagic((char *)p); freeMagic1(&mm1, (char *)p);
freeMagic1_end(&mm1);
devMergeList = NULL; devMergeList = NULL;
} }
@ -812,7 +814,10 @@ main(
EFVisitDevs(simmergeVisit, PTR2CD(NULL)); EFVisitDevs(simmergeVisit, PTR2CD(NULL));
TxPrintf("Devices merged: %d\n", esDevsMerged); TxPrintf("Devices merged: %d\n", esDevsMerged);
esFMIndex = 0; esFMIndex = 0;
for (p = devMergeList; p != NULL; p = p->next) freeMagic((char *)p); free_magic1_t mm1 = freeMagic1_init();
for (p = devMergeList; p != NULL; p = p->next)
freeMagic1(&mm1, (char *)p);
freeMagic1_end(&mm1);
} }
EFVisitDevs(simdevVisit, PTR2CD(NULL)); EFVisitDevs(simdevVisit, PTR2CD(NULL));

View File

@ -2201,11 +2201,13 @@ esMakePorts(
} }
/* Free table data */ /* Free table data */
free_magic1_t mm1 = freeMagic1_init();
while (flagtop != NULL) while (flagtop != NULL)
{ {
freeMagic((char *)flagtop); freeMagic1(&mm1, (char *)flagtop);
flagtop = flagtop->fdr_next; flagtop = flagtop->fdr_next;
} }
freeMagic1_end(&mm1);
HashKill(&flagHashTable); HashKill(&flagHashTable);
return 0; return 0;
} }
@ -2337,8 +2339,10 @@ esHierVisit(
EFHierVisitDevs(hcf, spcdevHierMergeVisit, (ClientData)NULL); EFHierVisitDevs(hcf, spcdevHierMergeVisit, (ClientData)NULL);
TxPrintf("Devs merged: %d\n", esSpiceDevsMerged); TxPrintf("Devs merged: %d\n", esSpiceDevsMerged);
esFMIndex = 0; esFMIndex = 0;
free_magic1_t mm1 = freeMagic1_init();
for (p = devMergeList; p != NULL; p = p->next) for (p = devMergeList; p != NULL; p = p->next)
freeMagic((char *)p); freeMagic1(&mm1, (char *)p);
freeMagic1_end(&mm1);
devMergeList = NULL; devMergeList = NULL;
} }
else if (esDistrJunct) else if (esDistrJunct)

View File

@ -1104,8 +1104,10 @@ runexttospice:
fprintf(esSpiceF, " "); fprintf(esSpiceF, " ");
freeMagic(glist->gll_name); freeMagic(glist->gll_name);
freeMagic(glist); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, glist);
glist = glist->gll_next; glist = glist->gll_next;
freeMagic1_end(&mm1);
} }
fprintf(esSpiceF, "\n\n"); fprintf(esSpiceF, "\n\n");
} }
@ -1159,8 +1161,10 @@ runexttospice:
EFVisitDevs(devMergeVisit, (ClientData) NULL); EFVisitDevs(devMergeVisit, (ClientData) NULL);
TxPrintf("Devs merged: %d\n", esSpiceDevsMerged); TxPrintf("Devs merged: %d\n", esSpiceDevsMerged);
esFMIndex = 0; esFMIndex = 0;
free_magic1_t mm1 = freeMagic1_init();
for (p = devMergeList; p != NULL; p = p->next) for (p = devMergeList; p != NULL; p = p->next)
freeMagic((char *) p); freeMagic1(&mm1, (char *) p);
freeMagic1_end(&mm1);
devMergeList = NULL; devMergeList = NULL;
} }
else if (esDistrJunct) else if (esDistrJunct)
@ -1341,9 +1345,12 @@ main(
TxPrintf("Devs merged: %d\n", esSpiceDevsMerged); TxPrintf("Devs merged: %d\n", esSpiceDevsMerged);
esFMIndex = 0 ; esFMIndex = 0 ;
{ {
const devMerge *p; const devMerge *p;
for ( p = devMergeList ; p != NULL ; p=p->next ) freeMagic((char *)p); free_magic1_t mm1 = freeMagic1_init();
for (p = devMergeList; p != NULL; p = p->next)
freeMagic1(&mm1, (char *)p);
freeMagic1_end(&mm1);
} }
} else if ( esDistrJunct ) } else if ( esDistrJunct )
EFVisitDevs(devDistJunctVisit, (ClientData) NULL); EFVisitDevs(devDistJunctVisit, (ClientData) NULL);
@ -1905,8 +1912,10 @@ topVisit(
sname = lnn->lnn_nodeName; sname = lnn->lnn_nodeName;
if (esDoBlackBox == FALSE || !(def->def_flags & DEF_ABSTRACT)) if (esDoBlackBox == FALSE || !(def->def_flags & DEF_ABSTRACT))
sname->efnn_port = ++portmax; sname->efnn_port = ++portmax;
freeMagic(lnn); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, lnn);
lnn = lnn->lnn_next; lnn = lnn->lnn_next;
freeMagic1_end(&mm1);
} }
/* Port numbers need not start at zero or be contiguous. They will be */ /* Port numbers need not start at zero or be contiguous. They will be */

View File

@ -603,33 +603,57 @@ efBuildEquiv(def, nodeName1, nodeName2, resist, isspice)
} }
if (!equalByCase) if (!equalByCase)
{ {
if ((EFOutputFlags & EF_SHORT_MASK) != EF_SHORT_NONE) /* If one of the nodes has been generated from the
* other by "extract unique", then this is a case where
* the "extract unique" algorithm is blind to shorts
* through subcell hierarchy and has made a name unique
* unnecessarily. In that case, merge the node instead
* of generating a short.
*/
char *uniqstr1, *uniqstr2;
bool isuniq;
uniqstr1 = strstr(nodeName1, "_uq");
uniqstr2 = strstr(nodeName2, "_uq");
if (uniqstr1) *uniqstr1 = '\0';
if (uniqstr2) *uniqstr2 = '\0';
isuniq = !strcmp(nodeName1, nodeName2);
if (uniqstr1) *uniqstr1 = '_';
if (uniqstr2) *uniqstr2 = '_';
if (!isuniq)
{ {
int i; if ((EFOutputFlags & EF_SHORT_MASK) != EF_SHORT_NONE)
int sdev; {
char *argv[10], zeroarg[] = "0"; int i;
int sdev;
char *argv[10], zeroarg[] = "0";
if ((EFOutputFlags & EF_SHORT_MASK) == EF_SHORT_R) if ((EFOutputFlags & EF_SHORT_MASK) == EF_SHORT_R)
sdev = DEV_RES; sdev = DEV_RES;
else
sdev = DEV_VOLT;
for (i = 0; i < 10; i++) argv[i] = zeroarg;
argv[0] = StrDup((char **)NULL, "0.0");
argv[1] = StrDup((char **)NULL, "dummy");
argv[4] = StrDup((char **)NULL, nodeName1);
argv[7] = StrDup((char **)NULL, nodeName2);
efBuildDevice(def, sdev, "None", &GeoNullRect, 10, argv);
freeMagic(argv[0]);
freeMagic(argv[1]);
freeMagic(argv[4]);
freeMagic(argv[7]);
return;
}
else if (!resist)
TxError("Warning: Ports \"%s\" and \"%s\" are electrically "
"shorted.\n", nodeName1, nodeName2);
else else
sdev = DEV_VOLT; /* Do not merge the nodes when folding in extresist parasitics */
return;
for (i = 0; i < 10; i++) argv[i] = zeroarg;
argv[0] = StrDup((char **)NULL, "0.0");
argv[1] = StrDup((char **)NULL, "dummy");
argv[4] = StrDup((char **)NULL, nodeName1);
argv[7] = StrDup((char **)NULL, nodeName2);
efBuildDevice(def, sdev, "None", &GeoNullRect, 10, argv);
freeMagic(argv[0]);
freeMagic(argv[1]);
freeMagic(argv[4]);
freeMagic(argv[7]);
return;
} }
else if (!resist) else if (resist)
TxError("Warning: Ports \"%s\" and \"%s\" are electrically shorted.\n",
nodeName1, nodeName2);
else
/* Do not merge the nodes when folding in extresist parasitics */ /* Do not merge the nodes when folding in extresist parasitics */
return; return;
} }
@ -652,8 +676,6 @@ efBuildEquiv(def, nodeName1, nodeName2, resist, isspice)
if (efWarn) if (efWarn)
efReadError("Merged nodes %s and %s\n", nodeName1, nodeName2); efReadError("Merged nodes %s and %s\n", nodeName1, nodeName2);
lostnode = efNodeMerge(&nn1->efnn_node, &nn2->efnn_node); lostnode = efNodeMerge(&nn1->efnn_node, &nn2->efnn_node);
if (nn1->efnn_port > 0) nn2->efnn_port = nn1->efnn_port;
else if (nn2->efnn_port > 0) nn1->efnn_port = nn2->efnn_port;
/* Check if there are any device terminals pointing to the /* Check if there are any device terminals pointing to the
* node that was just removed. * node that was just removed.
@ -1484,6 +1506,34 @@ efBuildUse(def, subDefName, subUseId, ta, tb, tc, td, te, tf)
HashSetValue(he, (ClientData)newuse); HashSetValue(he, (ClientData)newuse);
} }
/*
* ----------------------------------------------------------------------------
*
* efConnectionFreeLinkedList --
*
* Release memory for linked-list of Connection* based on internal list
* at Connection->conn_next. 'conn' argument must be non-NULL.
*
* Results:
* Deallocates linked-list of Connection* starting at 'conn'
*
* Side effects:
* Deallocates one or more connection record(s).
*
* ----------------------------------------------------------------------------
*/
void
efConnectionFreeLinkedList(Connection *conn)
{
while (conn)
{
Connection *next = conn->conn_next;
efFreeConn(conn);
conn = next;
}
}
/* /*
* ---------------------------------------------------------------------------- * ----------------------------------------------------------------------------
* *
@ -1518,7 +1568,25 @@ efBuildConnect(def, nodeName1, nodeName2, deltaC, av, ac)
unsigned size = sizeof (Connection) unsigned size = sizeof (Connection)
+ (efNumResistClasses - 1) * sizeof (EFPerimArea); + (efNumResistClasses - 1) * sizeof (EFPerimArea);
if ((EFOutputFlags & EF_SHORT_MASK) != EF_SHORT_NONE) /* If one of the nodes has been generated from the
* other by "extract unique", then this is a case where
* the "extract unique" algorithm is blind to shorts
* through subcell hierarchy and has made a name unique
* unnecessarily. In that case, merge the node instead
* of generating a short.
*/
char *uniqstr1, *uniqstr2;
bool isuniq;
uniqstr1 = strstr(nodeName1, "_uq");
uniqstr2 = strstr(nodeName2, "_uq");
if (uniqstr1) *uniqstr1 = '\0';
if (uniqstr2) *uniqstr2 = '\0';
isuniq = !strcmp(nodeName1, nodeName2);
if (uniqstr1) *uniqstr1 = '_';
if (uniqstr2) *uniqstr2 = '_';
if (!isuniq && ((EFOutputFlags & EF_SHORT_MASK) != EF_SHORT_NONE))
{ {
/* Handle the case where two ports on different nets get merged. /* Handle the case where two ports on different nets get merged.
* If "extract short resistor" or "extract short voltage" has * If "extract short resistor" or "extract short voltage" has
@ -1921,8 +1989,10 @@ efNodeMerge(node1ptr, node2ptr)
if (*node1ptr == *node2ptr) if (*node1ptr == *node2ptr)
return NULL; return NULL;
/* Keep the node with the greater number of entries, and merge */ /*
/* the node with fewer entries into it. */ * Keep the node with the greater number of entries, and merge
* the node with fewer entries into it.
*/
if ((*node1ptr)->efnode_num >= (*node2ptr)->efnode_num) if ((*node1ptr)->efnode_num >= (*node2ptr)->efnode_num)
{ {
@ -1962,7 +2032,7 @@ efNodeMerge(node1ptr, node2ptr)
/* Make all EFNodeNames point to "keeping" */ /* Make all EFNodeNames point to "keeping" */
if (removing->efnode_name) if (removing->efnode_name)
{ {
bool topportk, topportr; bool topportk, topportr, bestname;
for (nn = removing->efnode_name; nn; nn = nn->efnn_next) for (nn = removing->efnode_name; nn; nn = nn->efnn_next)
{ {
@ -1974,9 +2044,9 @@ efNodeMerge(node1ptr, node2ptr)
topportr = (removing->efnode_flags & EF_TOP_PORT) ? TRUE : FALSE; topportr = (removing->efnode_flags & EF_TOP_PORT) ? TRUE : FALSE;
/* Concatenate list of EFNodeNames, taking into account precedence */ /* Concatenate list of EFNodeNames, taking into account precedence */
if ((!keeping->efnode_name) || (!topportk && (topportr if ((!keeping->efnode_name) || (!topportk && topportr)
|| EFHNBest(removing->efnode_name->efnn_hier, || EFHNBest(removing->efnode_name->efnn_hier,
keeping->efnode_name->efnn_hier)))) keeping->efnode_name->efnn_hier))
{ {
/* /*
* New official name is that of "removing". * New official name is that of "removing".
@ -2240,23 +2310,33 @@ efFreeNodeList(head, func)
EFAttr *ap; EFAttr *ap;
LinkedRect *lr; LinkedRect *lr;
free_magic1_t mm1 = freeMagic1_init();
for (node = (EFNode *) head->efnode_next; for (node = (EFNode *) head->efnode_next;
node != head; node != head;
node = (EFNode *) node->efnode_next) node = (EFNode *) node->efnode_next)
{ {
for (ap = node->efnode_attrs; ap; ap = ap->efa_next) {
freeMagic((char *) ap); free_magic1_t mm1_ = freeMagic1_init();
for (ap = node->efnode_attrs; ap; ap = ap->efa_next)
freeMagic1(&mm1_, (char *) ap);
freeMagic1_end(&mm1_);
}
if (node->efnode_client != (ClientData)NULL) if (node->efnode_client != (ClientData)NULL)
{ {
if (func != NULL) if (func != NULL)
(*func)(node->efnode_client); (*func)(node->efnode_client);
freeMagic((char *)node->efnode_client); freeMagic((char *)node->efnode_client);
} }
for (lr = node->efnode_disjoint; lr; lr = lr->r_next) {
freeMagic((char *)lr); free_magic1_t mm1_ = freeMagic1_init();
for (lr = node->efnode_disjoint; lr; lr = lr->r_next)
freeMagic1(&mm1_, (char *)lr);
freeMagic1_end(&mm1_);
}
freeMagic((char *) node); freeMagic1(&mm1, (char *) node);
} }
freeMagic1_end(&mm1);
} }
/* /*

View File

@ -119,18 +119,17 @@ EFDone(func)
HashKill(&def->def_dists); HashKill(&def->def_dists);
HashKill(&def->def_uses); HashKill(&def->def_uses);
HashKill(&def->def_devs); HashKill(&def->def_devs);
for (conn = def->def_conns; conn; conn = conn->conn_next) efConnectionFreeLinkedList(def->def_conns);
efFreeConn(conn); efConnectionFreeLinkedList(def->def_caps);
for (conn = def->def_caps; conn; conn = conn->conn_next) efConnectionFreeLinkedList(def->def_resistors);
efFreeConn(conn);
for (conn = def->def_resistors; conn; conn = conn->conn_next)
efFreeConn(conn);
free_magic1_t mm1 = freeMagic1_init();
for (kill = def->def_kills; kill; kill = kill->kill_next) for (kill = def->def_kills; kill; kill = kill->kill_next)
{ {
freeMagic(kill->kill_name); freeMagic(kill->kill_name);
freeMagic((char *) kill); freeMagic1(&mm1, (char *) kill);
} }
freeMagic1_end(&mm1);
freeMagic((char *) def); freeMagic((char *) def);
} }
@ -157,8 +156,10 @@ EFDone(func)
while (plist != NULL) while (plist != NULL)
{ {
freeMagic(plist->parm_name); freeMagic(plist->parm_name);
freeMagic(plist); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, plist);
plist = plist->parm_next; plist = plist->parm_next;
freeMagic1_end(&mm1);
} }
} }
HashKill(&efDevParamTable); HashKill(&efDevParamTable);

View File

@ -306,6 +306,7 @@ extern void CapHashSetValue();
extern DevParam *efGetDeviceParams(); extern DevParam *efGetDeviceParams();
extern void efBuildNode(); extern void efBuildNode();
extern void efConnectionFreeLinkedList(Connection *conn);
extern void efBuildConnect(); extern void efBuildConnect();
extern void efBuildResistor(); extern void efBuildResistor();
extern void efBuildCap(); extern void efBuildCap();

View File

@ -465,18 +465,20 @@ EFHNFree(hierName, prefix, type)
{ {
HierName *hn; HierName *hn;
free_magic1_t mm1 = freeMagic1_init();
for (hn = hierName; hn; hn = hn->hn_parent) for (hn = hierName; hn; hn = hn->hn_parent)
{ {
if (hn == prefix) if (hn == prefix)
break; break;
freeMagic((char *) hn); freeMagic1(&mm1, (char *) hn);
if (efHNStats) if (efHNStats)
{ {
int len = strlen(hn->hn_name); int len = strlen(hn->hn_name);
efHNRecord(-HIERNAMESIZE(len), type); efHNRecord(-HIERNAMESIZE(len), type);
} }
} }
freeMagic1_end(&mm1);
} }
/* /*

View File

@ -95,6 +95,7 @@ extOutputGeneratedLabels(parentUse, f)
parentDef = parentUse->cu_def; parentDef = parentUse->cu_def;
free_magic1_t mm1 = freeMagic1_init();
while ((lab = parentDef->cd_labels) != NULL) while ((lab = parentDef->cd_labels) != NULL)
{ {
if ((lab->lab_flags & LABEL_GENERATE) == 0) return; if ((lab->lab_flags & LABEL_GENERATE) == 0) return;
@ -106,9 +107,10 @@ extOutputGeneratedLabels(parentUse, f)
for (n = 0; n < ExtCurStyle->exts_numResistClasses; n++) for (n = 0; n < ExtCurStyle->exts_numResistClasses; n++)
fprintf(f, " 0 0"); fprintf(f, " 0 0");
putc('\n', f); putc('\n', f);
freeMagic(lab); freeMagic1(&mm1, lab);
parentDef->cd_labels = lab->lab_next; parentDef->cd_labels = lab->lab_next;
} }
freeMagic1_end(&mm1);
} }
#endif #endif

View File

@ -2361,8 +2361,10 @@ extOutputDevices(def, transList, outFile)
break; break;
} }
} }
free_magic1_t mm1 = freeMagic1_init();
for (lt = extSpecialDevice; lt; lt = lt->t_next) for (lt = extSpecialDevice; lt; lt = lt->t_next)
freeMagic((char *)lt); freeMagic1(&mm1, (char *)lt);
freeMagic1_end(&mm1);
} }
} }
else else
@ -2679,8 +2681,12 @@ extOutputDevices(def, transList, outFile)
/* Free the lists */ /* Free the lists */
for (i = 0; i < extTransRec.tr_nterm; i++) for (i = 0; i < extTransRec.tr_nterm; i++)
{
free_magic1_t mm1 = freeMagic1_init();
for (lb = extSpecialBounds[i]; lb != NULL; lb = lb->b_next) for (lb = extSpecialBounds[i]; lb != NULL; lb = lb->b_next)
freeMagic((char *)lb); freeMagic1(&mm1, (char *)lb);
freeMagic1_end(&mm1);
}
freeMagic((char *)extSpecialBounds); freeMagic((char *)extSpecialBounds);
/* Put the region list back the way we found it: */ /* Put the region list back the way we found it: */
@ -2770,8 +2776,12 @@ extOutputDevices(def, transList, outFile)
/* Free the lists */ /* Free the lists */
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{
free_magic1_t mm1 = freeMagic1_init();
for (lb = extSpecialBounds[i]; lb != NULL; lb = lb->b_next) for (lb = extSpecialBounds[i]; lb != NULL; lb = lb->b_next)
freeMagic((char *)lb); freeMagic1(&mm1, (char *)lb);
freeMagic1_end(&mm1);
}
freeMagic((char *)extSpecialBounds); freeMagic((char *)extSpecialBounds);
/* Put the region list back the way we found it: */ /* Put the region list back the way we found it: */
@ -2868,8 +2878,12 @@ extOutputDevices(def, transList, outFile)
/* Free the lists */ /* Free the lists */
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{
free_magic1_t mm1 = freeMagic1_init();
for (lb = extSpecialBounds[i]; lb != NULL; lb = lb->b_next) for (lb = extSpecialBounds[i]; lb != NULL; lb = lb->b_next)
freeMagic((char *)lb); freeMagic1(&mm1, (char *)lb);
freeMagic1_end(&mm1);
}
freeMagic((char *)extSpecialBounds); freeMagic((char *)extSpecialBounds);
/* Put the region list back the way we found it: */ /* Put the region list back the way we found it: */
@ -3016,8 +3030,12 @@ extOutputDevices(def, transList, outFile)
/* Free the lists */ /* Free the lists */
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{
free_magic1_t mm1 = freeMagic1_init();
for (lb = extSpecialBounds[i]; lb != NULL; lb = lb->b_next) for (lb = extSpecialBounds[i]; lb != NULL; lb = lb->b_next)
freeMagic((char *)lb); freeMagic1(&mm1, (char *)lb);
freeMagic1_end(&mm1);
}
freeMagic((char *)extSpecialBounds); freeMagic((char *)extSpecialBounds);
/* Put the region list back the way we found it: */ /* Put the region list back the way we found it: */
@ -3850,12 +3868,14 @@ extTransPerimFunc(bp)
extTermAPFunc, (ClientData)&eapd); extTermAPFunc, (ClientData)&eapd);
shared = 1; shared = 1;
free_magic1_t mm1 = freeMagic1_init();
while (eapd.eapd_shared) while (eapd.eapd_shared)
{ {
shared++; shared++;
freeMagic(eapd.eapd_shared); freeMagic1(&mm1, eapd.eapd_shared);
eapd.eapd_shared = eapd.eapd_shared->nl_next; eapd.eapd_shared = eapd.eapd_shared->nl_next;
} }
freeMagic1_end(&mm1);
extTransRec.tr_termarea[thisterm] = eapd.eapd_area; extTransRec.tr_termarea[thisterm] = eapd.eapd_area;
extTransRec.tr_termperim[thisterm] = eapd.eapd_perim; extTransRec.tr_termperim[thisterm] = eapd.eapd_perim;

View File

@ -495,6 +495,7 @@ extHardFreeAll(def, tReg)
arg.fra_each = (int (*)()) NULL; arg.fra_each = (int (*)()) NULL;
arg.fra_region = (ExtRegion *) extUnInit; arg.fra_region = (ExtRegion *) extUnInit;
free_magic1_t mm1 = freeMagic1_init();
for (reg = tReg; reg; reg = reg->treg_next) for (reg = tReg; reg; reg = reg->treg_next)
{ {
/* Reset all ti_client fields to extUnInit */ /* Reset all ti_client fields to extUnInit */
@ -506,11 +507,16 @@ extHardFreeAll(def, tReg)
} }
/* Free all LabelLists and then the region */ /* Free all LabelLists and then the region */
for (ll = reg->treg_labels; ll; ll = ll->ll_next)
{ {
if (ll->ll_label->lab_flags & LABEL_GENERATE) freeMagic(ll->ll_label); free_magic1_t mm1_ = freeMagic1_init();
freeMagic((char *) ll); for (ll = reg->treg_labels; ll; ll = ll->ll_next)
{
if (ll->ll_label->lab_flags & LABEL_GENERATE) freeMagic(ll->ll_label);
freeMagic1(&mm1_, (char *) ll);
}
freeMagic1_end(&mm1_);
} }
freeMagic((char *) reg); freeMagic1(&mm1, (char *) reg);
} }
freeMagic1_end(&mm1);
} }

View File

@ -293,22 +293,30 @@ extLength(rootUse, f)
* each of the receivers. Free each driver label * each of the receivers. Free each driver label
* as it is processed. * as it is processed.
*/ */
for (dLab = dList; dLab; dLab = dLab->lab_next)
{ {
for (rLab = rList; rLab; rLab = rLab->lab_next) free_magic1_t mm1 = freeMagic1_init();
for (dLab = dList; dLab; dLab = dLab->lab_next)
{ {
extPathPairDistance(dLab, rLab, &min, &max); for (rLab = rList; rLab; rLab = rLab->lab_next)
fprintf(f, "distance %s %s %d %d\n", {
extPathPairDistance(dLab, rLab, &min, &max);
fprintf(f, "distance %s %s %d %d\n",
dLab->lab_text, rLab->lab_text, min, max); dLab->lab_text, rLab->lab_text, min, max);
} }
/* Free the driver label */ /* Free the driver label */
freeMagic((char *) dLab); freeMagic1(&mm1, (char *) dLab);
}
freeMagic1_end(&mm1);
} }
/* Free all the receiver labels built up during this iteration */ /* Free all the receiver labels built up during this iteration */
for (rLab = rList; rLab; rLab = rLab->lab_next) {
freeMagic((char *) rLab); free_magic1_t mm1 = freeMagic1_init();
for (rLab = rList; rLab; rLab = rLab->lab_next)
freeMagic1(&mm1, (char *) rLab);
freeMagic1_end(&mm1);
}
/* For sanity since we've freed the driver label list */ /* For sanity since we've freed the driver label list */
HashSetValue(he, (ClientData) NULL); HashSetValue(he, (ClientData) NULL);

View File

@ -426,8 +426,10 @@ extDefPush(defList)
while (defList != NULL) while (defList != NULL)
{ {
StackPush((ClientData)defList->ld_def, extDefStack); StackPush((ClientData)defList->ld_def, extDefStack);
freeMagic(defList); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, defList);
defList = defList->ld_next; defList = defList->ld_next;
freeMagic1_end(&mm1);
} }
} }
@ -569,8 +571,12 @@ extParents(use, doExtract)
extDefListFunc(use, &defList); extDefListFunc(use, &defList);
/* use->cu_def is on the top of the list, so remove it */ /* use->cu_def is on the top of the list, so remove it */
freeMagic(defList); {
defList = defList->ld_next; free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, defList);
defList = defList->ld_next;
freeMagic1_end(&mm1);
}
while (defList != NULL) while (defList != NULL)
{ {
@ -585,8 +591,10 @@ extParents(use, doExtract)
sl = newsl; sl = newsl;
} }
freeMagic(defList); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, defList);
defList = defList->ld_next; defList = defList->ld_next;
freeMagic1_end(&mm1);
} }
/* Mark all defs as being unvisited */ /* Mark all defs as being unvisited */
@ -601,10 +609,14 @@ extParents(use, doExtract)
StackFree(extDefStack); StackFree(extDefStack);
/* Replace any modified substrate planes in use->cu_def's children */ /* Replace any modified substrate planes in use->cu_def's children */
for (; sl; sl = sl->sl_next)
{ {
ExtRevertSubstrate(sl->sl_def, sl->sl_plane); free_magic1_t mm1 = freeMagic1_init();
freeMagic(sl); for (; sl; sl = sl->sl_next)
{
ExtRevertSubstrate(sl->sl_def, sl->sl_plane);
freeMagic1(&mm1, sl);
}
freeMagic1_end(&mm1);
} }
} }
@ -765,8 +777,12 @@ ExtractOneCell(def, outName, doLength)
extDefListFunc(&dummyUse, &defList); extDefListFunc(&dummyUse, &defList);
/* def is on top of the list, so remove it */ /* def is on top of the list, so remove it */
freeMagic(defList); {
defList = defList->ld_next; free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, defList);
defList = defList->ld_next;
freeMagic1_end(&mm1);
}
/* Prepare substrates of all children of def */ /* Prepare substrates of all children of def */
while (defList != NULL) while (defList != NULL)
@ -781,8 +797,10 @@ ExtractOneCell(def, outName, doLength)
newsl->sl_next = sl; newsl->sl_next = sl;
sl = newsl; sl = newsl;
} }
freeMagic(defList); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, defList);
defList = defList->ld_next; defList = defList->ld_next;
freeMagic1_end(&mm1);
} }
savePlane = ExtCell(def, outName, doLength); savePlane = ExtCell(def, outName, doLength);
@ -790,11 +808,13 @@ ExtractOneCell(def, outName, doLength)
/* Restore all modified substrate planes */ /* Restore all modified substrate planes */
if (savePlane != NULL) ExtRevertSubstrate(def, savePlane); if (savePlane != NULL) ExtRevertSubstrate(def, savePlane);
free_magic1_t mm1 = freeMagic1_init();
for (; sl; sl = sl->sl_next) for (; sl; sl = sl->sl_next)
{ {
ExtRevertSubstrate(sl->sl_def, sl->sl_plane); ExtRevertSubstrate(sl->sl_def, sl->sl_plane);
freeMagic(sl); freeMagic1(&mm1, sl);
} }
freeMagic1_end(&mm1);
} }
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
@ -999,12 +1019,14 @@ extExtractStack(stack, doExtract, rootDef)
} }
/* Replace any modified substrate planes */ /* Replace any modified substrate planes */
free_magic1_t mm1 = freeMagic1_init();
for (; sl; sl = sl->sl_next) for (; sl; sl = sl->sl_next)
{ {
ExtRevertSubstrate(sl->sl_def, sl->sl_plane); ExtRevertSubstrate(sl->sl_def, sl->sl_plane);
sl->sl_def->cd_flags &= ~CDNOEXTRACT; sl->sl_def->cd_flags &= ~CDNOEXTRACT;
freeMagic(sl); freeMagic1(&mm1, sl);
} }
freeMagic1_end(&mm1);
if (!doExtract) if (!doExtract)
{ {

View File

@ -507,8 +507,10 @@ ExtFreeRegions(regList)
{ {
ExtRegion *reg; ExtRegion *reg;
free_magic1_t mm1 = freeMagic1_init();
for (reg = regList; reg; reg = reg->reg_next) for (reg = regList; reg; reg = reg->reg_next)
freeMagic((char *) reg); freeMagic1(&mm1, (char *) reg);
freeMagic1_end(&mm1);
} }
void void
@ -518,12 +520,16 @@ ExtFreeLabRegions(regList)
LabRegion *lreg; LabRegion *lreg;
LabelList *ll; LabelList *ll;
free_magic1_t mm1 = freeMagic1_init();
for (lreg = regList; lreg; lreg = lreg->lreg_next) for (lreg = regList; lreg; lreg = lreg->lreg_next)
{ {
free_magic1_t mm1_ = freeMagic1_init();
for (ll = lreg->lreg_labels; ll; ll = ll->ll_next) for (ll = lreg->lreg_labels; ll; ll = ll->ll_next)
freeMagic((char *) ll); freeMagic1(&mm1_, (char *) ll);
freeMagic((char *) lreg); freeMagic1_end(&mm1_);
freeMagic1(&mm1, (char *) lreg);
} }
freeMagic1_end(&mm1);
} }
void void
@ -533,13 +539,17 @@ ExtFreeHierLabRegions(regList)
ExtRegion *reg; ExtRegion *reg;
LabelList *ll; LabelList *ll;
free_magic1_t mm1 = freeMagic1_init();
for (reg = regList; reg; reg = reg->reg_next) for (reg = regList; reg; reg = reg->reg_next)
{ {
free_magic1_t mm1_ = freeMagic1_init();
for (ll = ((LabRegion *)reg)->lreg_labels; ll; ll = ll->ll_next) for (ll = ((LabRegion *)reg)->lreg_labels; ll; ll = ll->ll_next)
{ {
freeMagic((char *) ll->ll_label); freeMagic((char *) ll->ll_label);
freeMagic((char *) ll); freeMagic1(&mm1_, (char *) ll);
} }
freeMagic((char *) reg); freeMagic1_end(&mm1_);
freeMagic1(&mm1, (char *) reg);
} }
freeMagic1_end(&mm1);
} }

View File

@ -884,6 +884,7 @@ extTechStyleInit(style)
if (style->exts_device[r] != NULL) if (style->exts_device[r] != NULL)
{ {
ExtDevice *devptr; ExtDevice *devptr;
free_magic1_t mm1 = freeMagic1_init();
for (devptr = style->exts_device[r]; devptr; devptr = devptr->exts_next) for (devptr = style->exts_device[r]; devptr; devptr = devptr->exts_next)
{ {
@ -906,15 +907,18 @@ extTechStyleInit(style)
{ {
if (devptr->exts_deviceParams->pl_name != NULL) if (devptr->exts_deviceParams->pl_name != NULL)
freeMagic(devptr->exts_deviceParams->pl_name); freeMagic(devptr->exts_deviceParams->pl_name);
freeMagic(devptr->exts_deviceParams); free_magic1_t mm1_ = freeMagic1_init();
freeMagic1(&mm1_, devptr->exts_deviceParams);
devptr->exts_deviceParams = devptr->exts_deviceParams->pl_next; devptr->exts_deviceParams = devptr->exts_deviceParams->pl_next;
freeMagic1_end(&mm1_);
} }
} }
if (devptr->exts_deviceResist.ht_table != (HashEntry **) NULL) if (devptr->exts_deviceResist.ht_table != (HashEntry **) NULL)
HashKill(&devptr->exts_deviceResist); HashKill(&devptr->exts_deviceResist);
freeMagic(devptr); freeMagic1(&mm1, devptr);
} }
freeMagic1_end(&mm1);
style->exts_device[r] = (ExtDevice *)NULL; style->exts_device[r] = (ExtDevice *)NULL;
} }
} }
@ -1125,11 +1129,13 @@ ExtTechInit()
/* Forget all the extract style names */ /* Forget all the extract style names */
free_magic1_t mm1 = freeMagic1_init();
for (style = ExtAllStyles; style != NULL; style = style->exts_next) for (style = ExtAllStyles; style != NULL; style = style->exts_next)
{ {
freeMagic(style->exts_name); freeMagic(style->exts_name);
freeMagic(style); freeMagic1(&mm1, style);
} }
freeMagic1_end(&mm1);
ExtAllStyles = NULL; ExtAllStyles = NULL;
if (allExtractTypes == NULL) if (allExtractTypes == NULL)
@ -2626,8 +2632,10 @@ ExtTechLine(sectionName, argc, argv)
{ {
if (subcktParams->pl_name != NULL) if (subcktParams->pl_name != NULL)
freeMagic(subcktParams->pl_name); freeMagic(subcktParams->pl_name);
freeMagic(subcktParams); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, subcktParams);
subcktParams = subcktParams->pl_next; subcktParams = subcktParams->pl_next;
freeMagic1_end(&mm1);
} }
goto usage; goto usage;
} }

View File

@ -120,8 +120,10 @@ extHierFreeLabels(def)
{ {
Label *lab; Label *lab;
free_magic1_t mm1 = freeMagic1_init();
for (lab = def->cd_labels; lab; lab = lab->lab_next) for (lab = def->cd_labels; lab; lab = lab->lab_next)
freeMagic((char *) lab); freeMagic1(&mm1, (char *) lab);
freeMagic1_end(&mm1);
def->cd_labels = (Label *) NULL; def->cd_labels = (Label *) NULL;
} }

View File

@ -176,8 +176,10 @@ GCRFreeChannel(ch)
freeMagic((char *) ch->gcr_bPins); freeMagic((char *) ch->gcr_bPins);
freeMagic((char *) ch->gcr_lPins); freeMagic((char *) ch->gcr_lPins);
freeMagic((char *) ch->gcr_rPins); freeMagic((char *) ch->gcr_rPins);
free_magic1_t mm1 = freeMagic1_init();
for (net = ch->gcr_nets; net; net = net->gcr_next) for (net = ch->gcr_nets; net; net = net->gcr_next)
freeMagic((char *) net); freeMagic1(&mm1, (char *) net);
freeMagic1_end(&mm1);
freeMagic((char *) ch->gcr_lCol); freeMagic((char *) ch->gcr_lCol);
freeMagic((char *) ch->gcr_dRowsByCol); freeMagic((char *) ch->gcr_dRowsByCol);

View File

@ -127,8 +127,10 @@ bottom:
* the channel and cause the net structure to become invalid * the channel and cause the net structure to become invalid
* anyway. * anyway.
*/ */
free_magic1_t mm1 = freeMagic1_init();
for (net = ch->gcr_nets; net; net = net->gcr_next) for (net = ch->gcr_nets; net; net = net->gcr_next)
freeMagic((char *) net); freeMagic1(&mm1, (char *) net);
freeMagic1_end(&mm1);
ch->gcr_nets = NULL; ch->gcr_nets = NULL;
return (gcrRouterErrors); return (gcrRouterErrors);

View File

@ -309,6 +309,7 @@ w3dFillOps(trans, tile, cliprect, ztop, zbot)
} }
else else
{ {
free_magic1_t mm1 = freeMagic1_init();
for (segptr = tilesegs; segptr != NULL; segptr = segptr->r_next) for (segptr = tilesegs; segptr != NULL; segptr = segptr->r_next)
{ {
GeoTransRect(trans, &segptr->r_r, &r2); GeoTransRect(trans, &segptr->r_r, &r2);
@ -322,8 +323,9 @@ w3dFillOps(trans, tile, cliprect, ztop, zbot)
} }
else else
w3dFillEdge(&r, &r2, ztop, zbot); w3dFillEdge(&r, &r2, ztop, zbot);
freeMagic(segptr); freeMagic1(&mm1, segptr);
} }
freeMagic1_end(&mm1);
/* For non-manhattan tiles, GrBoxOutline only returns */ /* For non-manhattan tiles, GrBoxOutline only returns */
/* the manhattan edges. This leaves the (possibly */ /* the manhattan edges. This leaves the (possibly */

View File

@ -912,6 +912,7 @@ GrBox(MagWindow *mw, Transform *trans, Tile *tile)
} }
else else
{ {
free_magic1_t mm1 = freeMagic1_init();
/* non-rectangular box; requires drawing segments */ /* non-rectangular box; requires drawing segments */
for (segptr = tilesegs; segptr != NULL; segptr = segptr->r_next) for (segptr = tilesegs; segptr != NULL; segptr = segptr->r_next)
{ {
@ -924,8 +925,9 @@ GrBox(MagWindow *mw, Transform *trans, Tile *tile)
(*grDrawLinePtr)(r.r_xbot, r.r_ybot, r.r_xtop, r.r_ytop); (*grDrawLinePtr)(r.r_xbot, r.r_ybot, r.r_xtop, r.r_ytop);
/* Free memory, if it was allocated for outline segments */ /* Free memory, if it was allocated for outline segments */
freeMagic(segptr); freeMagic1(&mm1, segptr);
} }
freeMagic1_end(&mm1);
/* For non-manhattan tiles, the manhattan parts of the */ /* For non-manhattan tiles, the manhattan parts of the */
/* boundary have already been drawn. The diagonal boundary */ /* boundary have already been drawn. The diagonal boundary */

View File

@ -632,8 +632,10 @@ recovery:
GrStyleTable[i] = sstyle->style; GrStyleTable[i] = sstyle->style;
/* Add short style name reverse lookup table entry */ /* Add short style name reverse lookup table entry */
GrStyleNames[(int)(sstyle->shortname)] = i; GrStyleNames[(int)(sstyle->shortname)] = i;
freeMagic(sstyle); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, sstyle);
sstyle = sstyle->next; sstyle = sstyle->next;
freeMagic1_end(&mm1);
} }
} }
dstylehead = NULL; dstylehead = NULL;

View File

@ -209,9 +209,17 @@ grTkDefineCursor(glyphs)
return; return;
} }
#ifdef SUPPORT_DIRECT_MALLOC
glyphcache = (CursorCache *)malloc(sizeof(CursorCache));
#else
glyphcache = (CursorCache *)mallocMagic(sizeof(CursorCache)); glyphcache = (CursorCache *)mallocMagic(sizeof(CursorCache));
#endif
g->gr_cache = (ClientData)glyphcache; g->gr_cache = (ClientData)glyphcache;
g->gr_free = freeMagic; #ifdef SUPPORT_DIRECT_MALLOC
g->gr_free = free;
#else
g->gr_free = freeMagicLegacy;
#endif
/* Find the foreground and background colors of the glyph */ /* Find the foreground and background colors of the glyph */

View File

@ -763,11 +763,13 @@ glChanBlockDens(ch)
} }
/* Second pass to propagate blockages to nearby areas */ /* Second pass to propagate blockages to nearby areas */
free_magic1_t mm1 = freeMagic1_init();
for (pa = glChanPaintList, glChanPaintList = NULL; pa; pa = pa->pa_next) for (pa = glChanPaintList, glChanPaintList = NULL; pa; pa = pa->pa_next)
{ {
glChanFlood(&pa->pa_area, pa->pa_type); glChanFlood(&pa->pa_area, pa->pa_type);
freeMagic((char *) pa); freeMagic1(&mm1, (char *) pa);
} }
freeMagic1_end(&mm1);
} while (glChanPaintList != NULL); } while (glChanPaintList != NULL);
} }

View File

@ -194,7 +194,7 @@ glDMAlloc(dm, top, cap)
dm->dm_max = 0; dm->dm_max = 0;
dm->dm_size = top + 1; dm->dm_size = top + 1;
dm->dm_cap = cap; dm->dm_cap = cap;
dm->dm_value = (short *) callocMagic((unsigned) (sizeof (short) * dm->dm_size)); dm->dm_value = (short *) callocMagic(dm->dm_size, (unsigned) (sizeof (short)));
} }
/* /*

View File

@ -192,7 +192,7 @@ glClientInit(chanList, netList)
} }
for (net = netList->nnl_nets; net; net = net->nnet_next) for (net = netList->nnl_nets; net; net = net->nnet_next)
net->nnet_cdata = (ClientData) callocMagic((unsigned) (sizeof (NetClient))); net->nnet_cdata = (ClientData) callocMagic(1, (unsigned) (sizeof (NetClient)));
} }
/* /*
@ -238,8 +238,10 @@ glClientFree(chanList, netList)
for (net = netList->nnl_nets; net; net = net->nnet_next) for (net = netList->nnl_nets; net; net = net->nnet_next)
{ {
nclient = (NetClient *) net->nnet_cdata; nclient = (NetClient *) net->nnet_cdata;
free_magic1_t mm1 = freeMagic1_init();
for (cz = nclient->nc_pens; cz; cz = cz->cz_next) for (cz = nclient->nc_pens; cz; cz = cz->cz_next)
freeMagic((char *) cz); freeMagic1(&mm1, (char *) cz);
freeMagic1_end(&mm1);
net->nnet_cdata = (ClientData) NULL; net->nnet_cdata = (ClientData) NULL;
} }
} }

View File

@ -188,8 +188,10 @@ glPathFreePerm(list)
{ {
GlPoint *p; GlPoint *p;
free_magic1_t mm1 = freeMagic1_init();
for (p = list; p; p = p->gl_path) for (p = list; p; p = p->gl_path)
freeMagic((char *) p); freeMagic1(&mm1, (char *) p);
freeMagic1_end(&mm1);
return 0; return 0;
} }

View File

@ -103,8 +103,10 @@ glPenClearPerChan(net)
czNet = czNet->cz_next) czNet = czNet->cz_next)
{ {
gc = (GlobChan *) czNet->cz_chan->gcr_client; gc = (GlobChan *) czNet->cz_chan->gcr_client;
free_magic1_t mm1 = freeMagic1_init();
for (czChan = gc->gc_penList; czChan; czChan = czChan->cz_next) for (czChan = gc->gc_penList; czChan; czChan = czChan->cz_next)
freeMagic((char *) czChan); freeMagic1(&mm1, (char *) czChan);
freeMagic1_end(&mm1);
gc->gc_penList = (CZone *) NULL; gc->gc_penList = (CZone *) NULL;
} }
return 0; return 0;
@ -457,8 +459,10 @@ glPenAssignCosts(cz, netList)
} }
/* Cleanup */ /* Cleanup */
free_magic1_t mm1 = freeMagic1_init();
for (ns = crossNets; ns; ns = ns->ns_next) for (ns = crossNets; ns; ns = ns->ns_next)
freeMagic((char *) ns); freeMagic1(&mm1, (char *) ns);
freeMagic1_end(&mm1);
freeMagic((char *) crossArray); freeMagic((char *) crossArray);
} }

View File

@ -505,8 +505,10 @@ glHistoDump()
fprintf(fp, "TOTAL: %d\n", total); fprintf(fp, "TOTAL: %d\n", total);
/* Free memory */ /* Free memory */
free_magic1_t mm1 = freeMagic1_init();
for (gh = glNetHistoList; gh; gh = gh->glh_next) for (gh = glNetHistoList; gh; gh = gh->glh_next)
freeMagic((char *) gh); freeMagic1(&mm1, (char *) gh);
freeMagic1_end(&mm1);
glNetHistoList = NULL; glNetHistoList = NULL;
/* Done */ /* Done */

View File

@ -699,6 +699,7 @@ endCoord:
/* Process each segment and paint into the layout */ /* Process each segment and paint into the layout */
free_magic1_t mm1 = freeMagic1_init();
while (routeTop != NULL) while (routeTop != NULL)
{ {
/* paint */ /* paint */
@ -752,9 +753,10 @@ endCoord:
} }
/* advance to next point and free record (1-delayed) */ /* advance to next point and free record (1-delayed) */
freeMagic((char *)routeTop); freeMagic1(&mm1, (char *)routeTop);
routeTop = routeTop->r_next; routeTop = routeTop->r_next;
} }
freeMagic1_end(&mm1);
return token; /* Pass back the last token found */ return token; /* Pass back the last token found */
} }
@ -1633,6 +1635,7 @@ DefReadPins(
else else
flags |= LABEL_STICKY; flags |= LABEL_STICKY;
free_magic1_t mm1 = freeMagic1_init();
while (rectList != NULL) while (rectList != NULL)
{ {
GeoTransRect(&t, &rectList->r_r, &topRect); GeoTransRect(&t, &rectList->r_r, &topRect);
@ -1658,9 +1661,10 @@ DefReadPins(
GEO_CENTER, pinname, GEO_CENTER, pinname,
rectList->r_type, rectList->r_type,
pinDir | pinUse | flags, pinNum); pinDir | pinUse | flags, pinNum);
freeMagic(rectList); freeMagic1(&mm1, rectList);
rectList = rectList->r_next; rectList = rectList->r_next;
} }
freeMagic1_end(&mm1);
pending = FALSE; pending = FALSE;
pinNum++; pinNum++;
} }
@ -1681,6 +1685,7 @@ DefReadPins(
else else
flags |= LABEL_STICKY; flags |= LABEL_STICKY;
free_magic1_t mm1 = freeMagic1_init();
while (rectList != NULL) while (rectList != NULL)
{ {
GeoTransRect(&t, &rectList->r_r, &topRect); GeoTransRect(&t, &rectList->r_r, &topRect);
@ -1715,9 +1720,10 @@ DefReadPins(
GEO_CENTER, pinname, GEO_CENTER, pinname,
rectList->r_type, rectList->r_type,
pinDir | pinUse | flags, pinNum); pinDir | pinUse | flags, pinNum);
freeMagic(rectList); freeMagic1(&mm1, rectList);
rectList = rectList->r_next; rectList = rectList->r_next;
} }
freeMagic1_end(&mm1);
pending = FALSE; pending = FALSE;
pinNum++; pinNum++;
} }

View File

@ -2559,6 +2559,7 @@ defWriteBlockages(
{ {
if (defobsdata.blockData[i] == NULL) continue; if (defobsdata.blockData[i] == NULL) continue;
fprintf(f, " - LAYER %s", defobsdata.baseNames[i]); fprintf(f, " - LAYER %s", defobsdata.baseNames[i]);
free_magic1_t mm1 = freeMagic1_init();
for (lr = defobsdata.blockData[i]; lr; lr = lr->r_next) for (lr = defobsdata.blockData[i]; lr; lr = lr->r_next)
{ {
fprintf(f, "\n RECT ( %.10g %.10g ) ( %.10g %.10g )", fprintf(f, "\n RECT ( %.10g %.10g ) ( %.10g %.10g )",
@ -2566,8 +2567,9 @@ defWriteBlockages(
(float)(lr->r_r.r_ybot * oscale), (float)(lr->r_r.r_ybot * oscale),
(float)(lr->r_r.r_xtop * oscale), (float)(lr->r_r.r_xtop * oscale),
(float)(lr->r_r.r_ytop * oscale)); (float)(lr->r_r.r_ytop * oscale));
freeMagic(lr); freeMagic1(&mm1, lr);
} }
freeMagic1_end(&mm1);
fprintf(f, " ;\n"); fprintf(f, " ;\n");
} }
fprintf(f, "END BLOCKAGES\n\n"); fprintf(f, "END BLOCKAGES\n\n");

View File

@ -532,8 +532,10 @@ CmdLef(
if (!strcasecmp(inet, "none")) if (!strcasecmp(inet, "none"))
{ {
/* Remove all net names from the list */ /* Remove all net names from the list */
free_magic1_t mm1 = freeMagic1_init();
for (lnn = lefIgnoreNets; lnn; lnn = lnn->lnn_next) for (lnn = lefIgnoreNets; lnn; lnn = lnn->lnn_next)
freeMagic(lnn); freeMagic1(&mm1, lnn);
freeMagic1_end(&mm1);
lefIgnoreNets = NULL; lefIgnoreNets = NULL;
} }
else else

View File

@ -701,8 +701,10 @@ LefRedefined(
/* Only one name associated with the record, so */ /* Only one name associated with the record, so */
/* just clear all the allocated information. */ /* just clear all the allocated information. */
free_magic1_t mm1 = freeMagic1_init();
for (viaLR = lefl->info.via.lr; viaLR != NULL; viaLR = viaLR->r_next) for (viaLR = lefl->info.via.lr; viaLR != NULL; viaLR = viaLR->r_next)
freeMagic(viaLR); freeMagic1(&mm1, viaLR);
freeMagic1_end(&mm1);
newlefl = lefl; newlefl = lefl;
} }
else else
@ -1077,14 +1079,16 @@ LefReadPolygon(
plist = (Point *)mallocMagic(lpoints * sizeof(Point)); plist = (Point *)mallocMagic(lpoints * sizeof(Point));
lpoints = 0; lpoints = 0;
free_magic1_t mm1 = freeMagic1_init();
while (lr != NULL) while (lr != NULL)
{ {
plist[*ppoints - lpoints - 1].p_x = lr->r_r.r_xbot; plist[*ppoints - lpoints - 1].p_x = lr->r_r.r_xbot;
plist[*ppoints - lpoints - 1].p_y = lr->r_r.r_ybot; plist[*ppoints - lpoints - 1].p_y = lr->r_r.r_ybot;
freeMagic(lr); freeMagic1(&mm1, lr);
lpoints++; lpoints++;
lr = lr->r_next; lr = lr->r_next;
} }
freeMagic1_end(&mm1);
return plist; return plist;
} }
@ -1450,6 +1454,7 @@ LefReadPort(
rectList = LefReadGeometry(lefMacro, f, oscale, gdsOffset, TRUE, is_imported); rectList = LefReadGeometry(lefMacro, f, oscale, gdsOffset, TRUE, is_imported);
free_magic1_t mm1 = freeMagic1_init();
while (rectList != NULL) while (rectList != NULL)
{ {
if ((pinNum >= 0) || (lanno != NULL)) if ((pinNum >= 0) || (lanno != NULL))
@ -1529,9 +1534,10 @@ LefReadPort(
if (lanno != NULL) lanno = NULL; if (lanno != NULL) lanno = NULL;
} }
freeMagic((char *)rectList); freeMagic1(&mm1, (char *)rectList);
rectList = rectList->r_next; rectList = rectList->r_next;
} }
freeMagic1_end(&mm1);
} }
/* /*

View File

@ -1861,6 +1861,7 @@ lefWriteMacro(
DBPaint(lc.lefYank, &layerBound, ttype); DBPaint(lc.lefYank, &layerBound, ttype);
} }
free_magic1_t mm1 = freeMagic1_init();
for (thislll = lll; thislll; thislll = thislll->lll_next) for (thislll = lll; thislll; thislll = thislll->lll_next)
{ {
int mspace; int mspace;
@ -1879,8 +1880,9 @@ lefWriteMacro(
thislll->lll_area.r_ytop += mspace; thislll->lll_area.r_ytop += mspace;
DBErase(lc.lefYank, &thislll->lll_area, lab->lab_type); DBErase(lc.lefYank, &thislll->lll_area, lab->lab_type);
freeMagic(thislll); freeMagic1(&mm1, thislll);
} }
freeMagic1_end(&mm1);
if (setback >= 0) if (setback >= 0)
{ {

View File

@ -497,10 +497,12 @@ mzReclaimTCFunc(tile, notUsed)
Estimate *e; Estimate *e;
/* free estimates attached to tilecosts struc */ /* free estimates attached to tilecosts struc */
free_magic1_t mm1 = freeMagic1_init();
for(e=tc->tc_estimates; e!=NULL; e=e->e_next) for(e=tc->tc_estimates; e!=NULL; e=e->e_next)
{ {
freeMagic((char *) e); freeMagic1(&mm1, (char *) e);
} }
freeMagic1_end(&mm1);
/* free tilecosts struc */ /* free tilecosts struc */
freeMagic((char *) (tile->ti_client)); freeMagic((char *) (tile->ti_client));

View File

@ -123,16 +123,24 @@ MZFreeParameters(params)
RouteLayer *rL; RouteLayer *rL;
RouteContact *rC; RouteContact *rC;
for (rL = params->mp_rLayers; rL; rL = rL->rl_next)
{ {
ListDealloc(rL->rl_contactL); free_magic1_t mm1 = freeMagic1_init();
TiFreePlane(rL->rl_routeType.rt_hBlock); for (rL = params->mp_rLayers; rL; rL = rL->rl_next)
TiFreePlane(rL->rl_routeType.rt_vBlock); {
freeMagic(rL); ListDealloc(rL->rl_contactL);
TiFreePlane(rL->rl_routeType.rt_hBlock);
TiFreePlane(rL->rl_routeType.rt_vBlock);
freeMagic1(&mm1, rL);
}
freeMagic1_end(&mm1);
} }
for (rC = params->mp_rContacts; rC; rC = rC->rc_next) {
freeMagic(rC); free_magic1_t mm1 = freeMagic1_init();
for (rC = params->mp_rContacts; rC; rC = rC->rc_next)
freeMagic1(&mm1, rC);
freeMagic1_end(&mm1);
}
} }
@ -159,12 +167,14 @@ MZTechInit()
/* Clear out any old information */ /* Clear out any old information */
if (mzStyles != NULL) if (mzStyles != NULL)
{ {
free_magic1_t mm1 = freeMagic1_init();
for (style = mzStyles; style != NULL; style = style->ms_next) for (style = mzStyles; style != NULL; style = style->ms_next)
{ {
MZFreeParameters(&(style->ms_parms)); MZFreeParameters(&(style->ms_parms));
freeMagic(style->ms_name); freeMagic(style->ms_name);
freeMagic(style); freeMagic1(&mm1, style);
} }
freeMagic1_end(&mm1);
} }
/* Initially no route types defined */ /* Initially no route types defined */
@ -609,7 +619,7 @@ mzTechLayer(argc, argv)
} }
/* Allocate new route layer */ /* Allocate new route layer */
new = (RouteLayer *) callocMagic((unsigned) (sizeof (RouteLayer))); new = (RouteLayer *) callocMagic(1, (unsigned) (sizeof (RouteLayer)));
/* Initialize RouteType section */ /* Initialize RouteType section */
mzInitRouteType(&(new->rl_routeType),tileType); mzInitRouteType(&(new->rl_routeType),tileType);
@ -1143,7 +1153,7 @@ mzTechContact(argc, argv)
if(tileType < 0) return; if(tileType < 0) return;
/* allocate new route contact */ /* allocate new route contact */
new = (RouteContact *) callocMagic((unsigned) (sizeof (RouteContact))); new = (RouteContact *) callocMagic(1, (unsigned) (sizeof (RouteContact)));
/* initialize RouteType section: /* initialize RouteType section:
* sets route type, initializes spacing array, etc. * sets route type, initializes spacing array, etc.

View File

@ -157,7 +157,8 @@ NMCmdCleanup(w, cmd)
* is in progress. * is in progress.
*/ */
for (p = nmCleanupList; p != NULL; p = p->nmcl_next) free_magic1_t mm1 = freeMagic1_init();
for (p = nmCleanupList; p != NULL; p = p->nmcl_next)
{ {
char answer[30]; char answer[30];
int indx, defaultValue; int indx, defaultValue;
@ -184,11 +185,15 @@ NMCmdCleanup(w, cmd)
switch (indx) switch (indx)
{ {
case 0: case 0:
{
free_magic1_t mm1_ = freeMagic1_init();
while (p != NULL) while (p != NULL)
{ {
freeMagic((char *) p); freeMagic1(&mm1_, (char *) p);
p = p->nmcl_next; p = p->nmcl_next;
} }
freeMagic1_end(&mm1_);
}
return; return;
case 1: case 1:
NMDeleteNet(p->nmcl_name); NMDeleteNet(p->nmcl_name);
@ -197,8 +202,9 @@ NMCmdCleanup(w, cmd)
NMDeleteTerm(p->nmcl_name); NMDeleteTerm(p->nmcl_name);
break; break;
} }
freeMagic((char *) p); freeMagic1(&mm1, (char *) p);
} }
freeMagic1_end(&mm1);
if (nmCleanupList == NULL) if (nmCleanupList == NULL)
TxPrintf("No problems found.\n"); TxPrintf("No problems found.\n");

View File

@ -350,14 +350,16 @@ NMDeleteNet(net)
*/ */
next = ne->ne_next; next = ne->ne_next;
free_magic1_t mm1 = freeMagic1_init();
while (TRUE) while (TRUE)
{ {
NMUndo(next->ne_name, net, NMUE_REMOVE); NMUndo(next->ne_name, net, NMUE_REMOVE);
HashSetValue(HashFind(&nmCurrentNetlist->nl_table, next->ne_name), 0); HashSetValue(HashFind(&nmCurrentNetlist->nl_table, next->ne_name), 0);
freeMagic((char *) next); freeMagic1(&mm1, (char *) next);
if (next == ne) break; if (next == ne) break;
next = next->ne_next; next = next->ne_next;
} }
freeMagic1_end(&mm1);
} }
/* /*

View File

@ -180,6 +180,7 @@ NMRipup()
*/ */
TTMaskZero(&maskBits); TTMaskZero(&maskBits);
free_magic1_t mm1 = freeMagic1_init();
while (list != NULL) while (list != NULL)
{ {
DBErase(EditCellUse->cu_def, &list->nmwa_area, list->nmwa_type); DBErase(EditCellUse->cu_def, &list->nmwa_area, list->nmwa_type);
@ -189,9 +190,10 @@ NMRipup()
DRCCheckThis(EditCellUse->cu_def, TT_CHECKPAINT, &list->nmwa_area); DRCCheckThis(EditCellUse->cu_def, TT_CHECKPAINT, &list->nmwa_area);
DBWAreaChanged(EditCellUse->cu_def, &list->nmwa_area, DBW_ALLWINDOWS, DBWAreaChanged(EditCellUse->cu_def, &list->nmwa_area, DBW_ALLWINDOWS,
&DBAllButSpaceBits); &DBAllButSpaceBits);
freeMagic((char *) list); freeMagic1(&mm1, (char *) list);
list = list->nmwa_next; list = list->nmwa_next;
} }
freeMagic1_end(&mm1);
DBReComputeBbox(EditCellUse->cu_def); DBReComputeBbox(EditCellUse->cu_def);
return 0; return 0;
} }
@ -240,6 +242,7 @@ nmRipLocFunc(rect, name, label, area)
&TiPlaneRect, nmwRipTileFunc, (ClientData) &list); &TiPlaneRect, nmwRipTileFunc, (ClientData) &list);
TTMaskZero(&maskBits); TTMaskZero(&maskBits);
TTMaskClearType(&maskBits, label->lab_type); TTMaskClearType(&maskBits, label->lab_type);
free_magic1_t mm1 = freeMagic1_init();
while (list != NULL) while (list != NULL)
{ {
DBErase(EditCellUse->cu_def, &list->nmwa_area, list->nmwa_type); DBErase(EditCellUse->cu_def, &list->nmwa_area, list->nmwa_type);
@ -247,9 +250,10 @@ nmRipLocFunc(rect, name, label, area)
(void) DBEraseLabel(EditCellUse->cu_def, &list->nmwa_area, &maskBits, NULL); (void) DBEraseLabel(EditCellUse->cu_def, &list->nmwa_area, &maskBits, NULL);
TTMaskClearType(&maskBits, list->nmwa_type); TTMaskClearType(&maskBits, list->nmwa_type);
(void) GeoInclude(&list->nmwa_area, area); (void) GeoInclude(&list->nmwa_area, area);
freeMagic((char *) list); freeMagic1(&mm1, (char *) list);
list = list->nmwa_next; list = list->nmwa_next;
} }
freeMagic1_end(&mm1);
return 0; return 0;
} }

View File

@ -181,23 +181,35 @@ PlotPSTechInit()
/* Clear out any old information */ /* Clear out any old information */
for (style = plotPSStyles; style != NULL; style = style->grs_next)
{ {
freeMagic((char *) style); free_magic1_t mm1 = freeMagic1_init();
for (style = plotPSStyles; style != NULL; style = style->grs_next)
{
freeMagic1(&mm1, (char *) style);
}
freeMagic1_end(&mm1);
plotPSStyles = NULL;
} }
plotPSStyles = NULL;
for (pattern = plotPSPatterns; pattern != NULL; pattern = pattern->pat_next)
{ {
freeMagic((char *) pattern); free_magic1_t mm1 = freeMagic1_init();
for (pattern = plotPSPatterns; pattern != NULL; pattern = pattern->pat_next)
{
freeMagic1(&mm1, (char *) pattern);
}
freeMagic1_end(&mm1);
plotPSPatterns = NULL;
} }
plotPSPatterns = NULL;
for (color = plotPSColors; color != NULL; color = color->col_next)
{ {
freeMagic((char *) color); free_magic1_t mm1 = freeMagic1_init();
for (color = plotPSColors; color != NULL; color = color->col_next)
{
freeMagic1(&mm1, (char *) color);
}
freeMagic1_end(&mm1);
plotPSColors = NULL;
} }
plotPSColors = NULL;
if (!PlotPSIdFont) if (!PlotPSIdFont)
StrDup(&PlotPSIdFont, defaultFont); StrDup(&PlotPSIdFont, defaultFont);

View File

@ -216,10 +216,12 @@ PlotVersTechInit()
{ {
VersatecStyle *style; VersatecStyle *style;
free_magic1_t mm1 = freeMagic1_init();
for (style = plotVersStyles; style != NULL; style = style->vs_next) for (style = plotVersStyles; style != NULL; style = style->vs_next)
{ {
freeMagic((char *) style); freeMagic1(&mm1, (char *) style);
} }
freeMagic1_end(&mm1);
plotVersStyles = NULL; plotVersStyles = NULL;
if (PlotVersPrinter == NULL) if (PlotVersPrinter == NULL)
@ -267,10 +269,12 @@ PlotColorVersTechInit()
{ {
VersatecStyle *style; VersatecStyle *style;
free_magic1_t mm1 = freeMagic1_init();
for (style = plotColorVersStyles; style != NULL; style = style->vs_next) for (style = plotColorVersStyles; style != NULL; style = style->vs_next)
{ {
freeMagic((char *) style); freeMagic1(&mm1, (char *) style);
} }
freeMagic1_end(&mm1);
plotColorVersStyles = NULL; plotColorVersStyles = NULL;
if (PlotVersPrinter == NULL) if (PlotVersPrinter == NULL)

View File

@ -239,11 +239,13 @@ PlowClearBound()
pb = plowBoundaryList; pb = plowBoundaryList;
plowCheckBoundary = FALSE; plowCheckBoundary = FALSE;
plowBoundaryList = (PlowBoundary *) NULL; plowBoundaryList = (PlowBoundary *) NULL;
free_magic1_t mm1 = freeMagic1_init();
for ( ; pb; pb = pb->pb_next) for ( ; pb; pb = pb->pb_next)
{ {
DBWHLRedraw(pb->pb_rootDef, &pb->pb_rootArea, TRUE); DBWHLRedraw(pb->pb_rootDef, &pb->pb_rootArea, TRUE);
freeMagic((char *) pb); freeMagic1(&mm1, (char *) pb);
} }
freeMagic1_end(&mm1);
} }
/* /*

View File

@ -127,11 +127,19 @@ PlowDRCInit()
{ {
for (j = 0; j < DBNumTypes; j++) for (j = 0; j < DBNumTypes; j++)
{ {
for (pr = plowWidthRulesTbl[i][j]; pr; pr = pr->pr_next) {
freeMagic((char *)pr); free_magic1_t mm1 = freeMagic1_init();
for (pr = plowWidthRulesTbl[i][j]; pr; pr = pr->pr_next)
freeMagic1(&mm1, (char *)pr);
freeMagic1_end(&mm1);
}
for (pr = plowSpacingRulesTbl[i][j]; pr; pr = pr->pr_next) {
freeMagic((char *)pr); free_magic1_t mm1 = freeMagic1_init();
for (pr = plowSpacingRulesTbl[i][j]; pr; pr = pr->pr_next)
freeMagic1(&mm1, (char *)pr);
freeMagic1_end(&mm1);
}
plowWidthRulesTbl[i][j] = NULL; plowWidthRulesTbl[i][j] = NULL;
plowSpacingRulesTbl[i][j] = NULL; plowSpacingRulesTbl[i][j] = NULL;
@ -697,6 +705,7 @@ plowTechOptimizeRule(ruleList)
*/ */
pCand = ruleList; pCand = ruleList;
pCandLast = (PlowRule *) NULL; pCandLast = (PlowRule *) NULL;
free_magic1_t mm1 = freeMagic1_init();
while (pCand) while (pCand)
{ {
for (pr = ruleList; pr; pr = pr->pr_next) for (pr = ruleList; pr; pr = pr->pr_next)
@ -718,7 +727,7 @@ plowTechOptimizeRule(ruleList)
* Delete pCand, and resume outer loop with the * Delete pCand, and resume outer loop with the
* new values of pCand and pCandLast set below. * new values of pCand and pCandLast set below.
*/ */
freeMagic((char *) pCand); freeMagic1(&mm1, (char *) pCand);
if (pCandLast) if (pCandLast)
pCandLast->pr_next = pCand->pr_next; pCandLast->pr_next = pCand->pr_next;
else else
@ -734,6 +743,7 @@ plowTechOptimizeRule(ruleList)
next: ; next: ;
} }
freeMagic1_end(&mm1);
return (ruleList); return (ruleList);
} }

View File

@ -92,6 +92,7 @@ resAllPortNodes(tile, list)
resPort *pl; resPort *pl;
tileJunk *junk = (tileJunk *)TiGetClientPTR(tile); tileJunk *junk = (tileJunk *)TiGetClientPTR(tile);
free_magic1_t mm1 = freeMagic1_init();
for (pl = junk->portList; pl; pl = pl->rp_nextPort) for (pl = junk->portList; pl; pl = pl->rp_nextPort)
{ {
x = pl->rp_loc.p_x; x = pl->rp_loc.p_x;
@ -103,8 +104,9 @@ resAllPortNodes(tile, list)
resptr->rn_name = pl->rp_nodename; resptr->rn_name = pl->rp_nodename;
ResAddToQueue(resptr, list); ResAddToQueue(resptr, list);
NEWBREAK(resptr, tile, x, y, NULL); NEWBREAK(resptr, tile, x, y, NULL);
freeMagic(pl); freeMagic1(&mm1, pl);
} }
freeMagic1_end(&mm1);
} }
/* /*

View File

@ -685,11 +685,13 @@ typedef enum {
HashKill(&ResProcessedTable); HashKill(&ResProcessedTable);
/* Revert substrate planes */ /* Revert substrate planes */
free_magic1_t mm1 = freeMagic1_init();
for (sl = resisdata.savePlanes; sl; sl = sl->sl_next) for (sl = resisdata.savePlanes; sl; sl = sl->sl_next)
{ {
ExtRevertSubstrate(sl->sl_def, sl->sl_plane); ExtRevertSubstrate(sl->sl_def, sl->sl_plane);
freeMagic(sl); freeMagic1(&mm1, sl);
} }
freeMagic1_end(&mm1);
/* turn back on undo stuff */ /* turn back on undo stuff */
UndoEnable(); UndoEnable();

View File

@ -173,6 +173,7 @@ RtrStemProcessAll(use, netList, doWarn, func)
* they all turned out to be unusable. * they all turned out to be unusable.
*/ */
locPrev = locFirst = (NLTermLoc *) NULL; locPrev = locFirst = (NLTermLoc *) NULL;
free_magic1_t mm1 = freeMagic1_init();
for (loc = term->nterm_locs; loc; loc = loc->nloc_next) for (loc = term->nterm_locs; loc; loc = loc->nloc_next)
{ {
if (loc->nloc_chan == (GCRChannel *) NULL) if (loc->nloc_chan == (GCRChannel *) NULL)
@ -187,13 +188,14 @@ RtrStemProcessAll(use, netList, doWarn, func)
/* Nuke it */ /* Nuke it */
if (locPrev) locPrev->nloc_next = loc->nloc_next; if (locPrev) locPrev->nloc_next = loc->nloc_next;
freeMagic((char *) loc); freeMagic1(&mm1, (char *) loc);
continue; continue;
} }
locPrev = loc; locPrev = loc;
if (locFirst == (NLTermLoc *) NULL) if (locFirst == (NLTermLoc *) NULL)
locFirst = loc; locFirst = loc;
} }
freeMagic1_end(&mm1);
/* Nuke any leading elements */ /* Nuke any leading elements */
term->nterm_locs = locFirst; term->nterm_locs = locFirst;

View File

@ -386,11 +386,13 @@ rtrViaCheck(area, def)
*/ */
DBErase(def, area, RtrContactType); DBErase(def, area, RtrContactType);
free_magic1_t mm1 = freeMagic1_init();
for ( pl = rtrPaintList; pl; pl = pl->pl_next) for ( pl = rtrPaintList; pl; pl = pl->pl_next)
{ {
DBPaint(def, &pl->pl_area, type); DBPaint(def, &pl->pl_area, type);
freeMagic( (char *)pl ); freeMagic1(&mm1, (char *)pl );
} }
freeMagic1_end(&mm1);
rtrVias++; rtrVias++;
return; return;
@ -523,21 +525,29 @@ RtrViaMinimize(def)
* Replace poly with metal where appropriate. * Replace poly with metal where appropriate.
*/ */
for ( ap = rtrAreaList; ap; ap = ap->ap_next)
{ {
DBErase(def, &ap->ap_erase, ap->ap_oldtype); free_magic1_t mm1 = freeMagic1_init();
DBPaint(def, &ap->ap_paint, ap->ap_newtype); for ( ap = rtrAreaList; ap; ap = ap->ap_next)
freeMagic( (char *)ap); {
DBErase(def, &ap->ap_erase, ap->ap_oldtype);
DBPaint(def, &ap->ap_paint, ap->ap_newtype);
freeMagic1(&mm1, (char *)ap);
}
freeMagic1_end(&mm1);
} }
/* /*
* Eliminate unnecessary vias. * Eliminate unnecessary vias.
*/ */
for ( vp = rtrViaList; vp; vp = vp->vp_next)
{ {
rtrViaCheck(&vp->vp_area, def); free_magic1_t mm1 = freeMagic1_init();
freeMagic( (char *)vp); for ( vp = rtrViaList; vp; vp = vp->vp_next)
{
rtrViaCheck(&vp->vp_area, def);
freeMagic1(&mm1, (char *)vp);
}
freeMagic1_end(&mm1);
} }
/* /*
@ -558,21 +568,29 @@ RtrViaMinimize(def)
* Erase poly and replace with metal. * Erase poly and replace with metal.
*/ */
for ( ap = rtrAreaList; ap; ap = ap->ap_next)
{ {
DBErase(def, &ap->ap_erase, ap->ap_oldtype); free_magic1_t mm1 = freeMagic1_init();
DBPaint(def, &ap->ap_paint, ap->ap_newtype); for ( ap = rtrAreaList; ap; ap = ap->ap_next)
freeMagic( (char *)ap); {
DBErase(def, &ap->ap_erase, ap->ap_oldtype);
DBPaint(def, &ap->ap_paint, ap->ap_newtype);
freeMagic1(&mm1, (char *)ap);
}
freeMagic1_end(&mm1);
} }
/* /*
* Eliminate unnecessary vias. * Eliminate unnecessary vias.
*/ */
for ( vp = rtrViaList; vp; vp = vp->vp_next)
{ {
rtrViaCheck(&vp->vp_area, def); free_magic1_t mm1 = freeMagic1_init();
freeMagic( (char *)vp); for ( vp = rtrViaList; vp; vp = vp->vp_next)
{
rtrViaCheck(&vp->vp_area, def);
freeMagic1(&mm1, (char *)vp);
}
freeMagic1_end(&mm1);
} }
return rtrVias; return rtrVias;

View File

@ -93,12 +93,29 @@ CC = @CC@
CPP = @CPP@ CPP = @CPP@
CXX = @CXX@ CXX = @CXX@
###
### Feature flags (to enable uncomment these from ./defs.mak after your ./configure)
###
### SUPPORT_DIRECT_MALLOC: this removes the legacy malloc/free APIs that are
### not thread-safe and have a defer-free-by-1 quirk that maybe covering
### up unknown problems. See utils/malloc.[ch] for more info.
###
### Status: EXPERIMENTAL (this is expected to uncover issues we don't know about yet)
#FEATURE_FLAGS += -DSUPPORT_DIRECT_MALLOC
###
### SUPPORT_REMOVE_MALLOC_LEGACY this completely removes the older non-threadsafe API
### from the output binaries.
### This option is dependent on SUPPORT_DIRECT_MALLOC
###
### Status: NOT-STABILITY-AFFECTING (if your binary links you are good to continue)
#FEATURE_FLAGS += -DSUPPORT_REMOVE_MALLOC_LEGACY
CPPFLAGS = -I${MAGICDIR} @CPPFLAGS@ CPPFLAGS = -I${MAGICDIR} @CPPFLAGS@
DFLAGS_MAGICVERSION = -DMAGIC_VERSION=\"${MAGIC_VERSION}\" -DMAGIC_REVISION=\"${MAGIC_REVISION}\" -DMAGIC_COMMIT=\"${MAGIC_COMMIT}\" "-DMAGIC_BUILDDATE=\"${MAGIC_BUILDDATE}\"" DFLAGS_MAGICVERSION = -DMAGIC_VERSION=\"${MAGIC_VERSION}\" -DMAGIC_REVISION=\"${MAGIC_REVISION}\" -DMAGIC_COMMIT=\"${MAGIC_COMMIT}\" "-DMAGIC_BUILDDATE=\"${MAGIC_BUILDDATE}\""
DFLAGS = @extra_defs@ @stub_defs@ @DEFS@ ${DFLAGS_MAGICVERSION} -DGCORE=\"@GCORE@\" DFLAGS = @extra_defs@ @stub_defs@ @DEFS@ ${DFLAGS_MAGICVERSION} -DGCORE=\"@GCORE@\"
DFLAGS += -DSHDLIB_EXT=\"@SHDLIB_EXT@\" @NDEBUG_defs@ @DEBUG_defs@ DFLAGS += -DSHDLIB_EXT=\"@SHDLIB_EXT@\" @NDEBUG_defs@ @DEBUG_defs@ ${FEATURE_FLAGS}
DFLAGS_NOSTUB = @extra_defs@ @DEFS@ ${DFLAGS_MAGICVERSION} -DGCORE=\"@GCORE@\" DFLAGS_NOSTUB = @extra_defs@ @DEFS@ ${DFLAGS_MAGICVERSION} -DGCORE=\"@GCORE@\"
DFLAGS_NOSTUB += -DSHDLIB_EXT=\"@SHDLIB_EXT@\" @NDEBUG_defs@ @DEBUG_defs@ DFLAGS_NOSTUB += -DSHDLIB_EXT=\"@SHDLIB_EXT@\" @NDEBUG_defs@ @DEBUG_defs@ ${FEATURE_FLAGS}
CFLAGS = @CFLAGS@ @SHLIB_CFLAGS@ @INC_SPECS@ CFLAGS = @CFLAGS@ @SHLIB_CFLAGS@ @INC_SPECS@
READLINE_DEFS = @rl_defs@ READLINE_DEFS = @rl_defs@

View File

@ -259,8 +259,10 @@ selEnumPFunc1(tile, arg)
if ((*arg->sea_func)(&rootRect, arg->sea_rectList->r_type, arg->sea_cdarg) != 0) if ((*arg->sea_func)(&rootRect, arg->sea_rectList->r_type, arg->sea_cdarg) != 0)
return 1; return 1;
freeMagic((char *)arg->sea_rectList); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, (char *)arg->sea_rectList);
arg->sea_rectList = arg->sea_rectList->r_next; arg->sea_rectList = arg->sea_rectList->r_next;
freeMagic1_end(&mm1);
} }
return 0; return 0;
} }

View File

@ -1595,8 +1595,10 @@ SelectStretch(x, y)
TTMaskSetOnlyType(&tmask, tloc); TTMaskSetOnlyType(&tmask, tloc);
DBPaintValid(EditCellUse->cu_def, &selStretchList->sa_area, &tmask, type); DBPaintValid(EditCellUse->cu_def, &selStretchList->sa_area, &tmask, type);
freeMagic((char *) selStretchList); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, (char *) selStretchList);
selStretchList = selStretchList->sa_next; selStretchList = selStretchList->sa_next;
freeMagic1_end(&mm1);
} }
/* Paint the new translated selection back into the edit cell, /* Paint the new translated selection back into the edit cell,

View File

@ -373,7 +373,13 @@ if {[info commands magic::openwrapper] != {}} {
foreach cellname $celllist { foreach cellname $celllist {
set fext [file extension $cellname] set fext [file extension $cellname]
puts stdout "handling file entry $cellname extension $fext" switch $fext {
.gz {}
"" {}
default {
puts stdout "Handling file entry $cellname extension $fext"
}
}
switch $fext { switch $fext {
.lef - .lef -
.LEF {lef read $cellname} .LEF {lef read $cellname}
@ -390,6 +396,16 @@ if {[info commands magic::openwrapper] != {}} {
.tcl {source $cellname} .tcl {source $cellname}
.mag - .mag -
"" {magic::load $cellname} "" {magic::load $cellname}
.gz {
set rootname [file root $cellname]
set fext [file extension $rootname]
puts stdout "Handling compressed entry $cellname extension $fext"
switch $fext {
.gds {gds read $cellname}
.mag {magic::load $cellname}
default {puts stderr "only compressed .mag and .gds are handled."}
}
}
default {puts stderr "don't know how to load file $cellname"} default {puts stderr "don't know how to load file $cellname"}
} }
} }

View File

@ -587,11 +587,12 @@ HashRemove(table, key)
bucket = hash(table, key); bucket = hash(table, key);
h = *(table->ht_table + bucket); h = *(table->ht_table + bucket);
hlast = NULL; hlast = NULL;
free_magic1_t mm1 = freeMagic1_init();
while (h != NIL) while (h != NIL)
{ {
if (strcmp(h->h_key.h_name, key) == 0) if (strcmp(h->h_key.h_name, key) == 0)
{ {
freeMagic((char *)h); freeMagic1(&mm1, (char *)h);
if (hlast != NULL) if (hlast != NULL)
hlast->h_next = h->h_next; hlast->h_next = h->h_next;
else else
@ -601,6 +602,7 @@ HashRemove(table, key)
hlast = h; hlast = h;
h = h->h_next; h = h->h_next;
} }
freeMagic1_end(&mm1);
} }
@ -690,16 +692,20 @@ HashKill(table)
if (table->ht_ptrKeys == HT_CLIENTKEYS) killFn = table->ht_killFn; if (table->ht_ptrKeys == HT_CLIENTKEYS) killFn = table->ht_killFn;
for (hp = table->ht_table, hend = &hp[table->ht_size]; hp < hend; hp++) for (hp = table->ht_table, hend = &hp[table->ht_size]; hp < hend; hp++)
{
free_magic1_t mm1 = freeMagic1_init();
for (h = *hp; h != NIL; h = h->h_next) for (h = *hp; h != NIL; h = h->h_next)
{ {
const void *p; const void *p;
freeMagic((char *) h); freeMagic1(&mm1, (char *) h);
if (killFn) if (killFn)
{ {
p = h->h_key.h_ptr; p = h->h_key.h_ptr;
(*killFn)((void *)p); (*killFn)((void *)p);
} }
} }
freeMagic1_end(&mm1);
}
freeMagic((char *) table->ht_table); freeMagic((char *) table->ht_table);
/* /*

View File

@ -73,7 +73,7 @@ extern IHashTable *IHashInit(
IHashTable *table; IHashTable *table;
table = (IHashTable *)mallocMagic(sizeof(IHashTable)); table = (IHashTable *)mallocMagic(sizeof(IHashTable));
table->iht_table = (void **)callocMagic(sizeof(void *)*nBuckets); table->iht_table = (void **)callocMagic(nBuckets, sizeof(void *));
table->iht_nBucketsInit = nBuckets; table->iht_nBucketsInit = nBuckets;
table->iht_nBuckets = nBuckets; table->iht_nBuckets = nBuckets;
table->iht_nEntries = 0; table->iht_nEntries = 0;
@ -99,7 +99,7 @@ void IHashClear(IHashTable *table)
{ {
/* reinitial bucket array */ /* reinitial bucket array */
freeMagic((char *) table->iht_table); freeMagic((char *) table->iht_table);
table->iht_table = (void **)callocMagic(sizeof(void *)*table->iht_nBucketsInit); table->iht_table = (void **)callocMagic(table->iht_nBucketsInit, sizeof(void *));
table->iht_nBuckets = table->iht_nBucketsInit; table->iht_nBuckets = table->iht_nBucketsInit;
table->iht_nEntries = 0; table->iht_nEntries = 0;
@ -217,7 +217,7 @@ static void iHashResize(IHashTable *table)
int bucket; int bucket;
/* alloc a new table */ /* alloc a new table */
table->iht_table = (void **)callocMagic(sizeof(void *)*newSize); table->iht_table = (void **)callocMagic(newSize, sizeof(void *));
table->iht_nBuckets = newSize; table->iht_nBuckets = newSize;
table->iht_nEntries = 0; table->iht_nEntries = 0;

View File

@ -98,8 +98,10 @@ void
ListDealloc(list) ListDealloc(list)
List *list; /* List to free */ List *list; /* List to free */
{ {
free_magic1_t mm1 = freeMagic1_init();
for(;list!=NULL; list=LIST_TAIL(list)) for(;list!=NULL; list=LIST_TAIL(list))
freeMagic((char *) list); freeMagic1(&mm1, (char *) list);
freeMagic1_end(&mm1);
return; return;
} }
@ -124,11 +126,13 @@ void
ListDeallocC(list) ListDeallocC(list)
List *list; /* List to free */ List *list; /* List to free */
{ {
free_magic1_t mm1 = freeMagic1_init();
for(;list!=NULL; list=LIST_TAIL(list)) for(;list!=NULL; list=LIST_TAIL(list))
{ {
freeMagic((char *) LIST_FIRST(list)); freeMagic1(&mm1, (char *) LIST_FIRST(list)); /* can probably use normal free() */
freeMagic((char *) list); freeMagic1(&mm1, (char *) list);
} }
freeMagic1_end(&mm1);
return; return;
} }

View File

@ -133,9 +133,11 @@ extern char *SysLibPath; /* Path for finding system
* Just for the sake of robustness, though, we define malloc and free * Just for the sake of robustness, though, we define malloc and free
* here to error strings. * here to error strings.
*/ */
#ifndef SUPPORT_DIRECT_MALLOC
#define malloc You_should_use_the_Magic_procedure_mallocMagic_instead #define malloc You_should_use_the_Magic_procedure_mallocMagic_instead
#define free You_should_use_the_Magic_procedure_freeMagic_instead #define free You_should_use_the_Magic_procedure_freeMagic_instead
#define calloc You_should_use_the_Magic_procedure_callocMagic_instead #define calloc You_should_use_the_Magic_procedure_callocMagic_instead
#endif
/* ---------- Flag for global variables (for readability) ------------- */ /* ---------- Flag for global variables (for readability) ------------- */

View File

@ -43,14 +43,18 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
#include <string.h> #include <string.h>
#include "tcltk/tclmagic.h" #include "tcltk/tclmagic.h"
#define _MAGIC__UTILS__MALLOC_H__NOINLINE
#include "utils/magic.h" #include "utils/magic.h"
#include "utils/malloc.h" #include "utils/malloc.h"
/* Normally we're supposed to warn against the use of standard malloc() */ /* Normally we're supposed to warn against the use of standard malloc() */
/* and free(), but obviously that doesn't apply to this file. */ /* and free(), but obviously that doesn't apply to this file. */
#ifndef SUPPORT_DIRECT_MALLOC
/* this is needed to remove the utils/magic.h defines */
#undef malloc #undef malloc
#undef free #undef free
#endif
/* Imports */ /* Imports */
@ -64,6 +68,7 @@ extern char *TxGetLine();
* would no further references would be made to free'ed storage. * would no further references would be made to free'ed storage.
*/ */
#ifndef SUPPORT_REMOVE_MALLOC_LEGACY
/* Delay free'ing by one call, to accommodate Magic's needs. */ /* Delay free'ing by one call, to accommodate Magic's needs. */
static char *freeDelayedItem = NULL; static char *freeDelayedItem = NULL;
@ -92,14 +97,14 @@ static char *freeDelayedItem = NULL;
/* /*
*--------------------------------------------------------------------- *---------------------------------------------------------------------
* mallocMagic() -- * mallocMagicLegacy() --
* *
* memory allocator with support for one-delayed-item free'ing * memory allocator with support for one-delayed-item free'ing
*--------------------------------------------------------------------- *---------------------------------------------------------------------
*/ */
void * void *
mallocMagic(nbytes) mallocMagicLegacy(nbytes)
size_t nbytes; size_t nbytes;
{ {
void *p; void *p;
@ -127,14 +132,14 @@ mallocMagic(nbytes)
/* /*
*--------------------------------------------------------------------- *---------------------------------------------------------------------
* freeMagic() -- * freeMagicLegacy() --
* *
* one-delayed-item memory deallocation * one-delayed-item memory deallocation
*--------------------------------------------------------------------- *---------------------------------------------------------------------
*/ */
void void
freeMagic(cp) freeMagicLegacy(cp)
void *cp; void *cp;
{ {
if (cp == NULL) if (cp == NULL)
@ -150,14 +155,14 @@ freeMagic(cp)
/* /*
*--------------------------------------------------------------------- *---------------------------------------------------------------------
* callocMagic() -- * callocMagicLegacy() --
* *
* allocate memory and initialize it to all zero bytes. * allocate memory and initialize it to all zero bytes.
*--------------------------------------------------------------------- *---------------------------------------------------------------------
*/ */
void * void *
callocMagic(nbytes) callocMagicLegacy(nbytes)
size_t nbytes; size_t nbytes;
{ {
void *cp; void *cp;
@ -168,3 +173,46 @@ callocMagic(nbytes)
return (cp); return (cp);
} }
#endif /* SUPPORT_REMOVE_MALLOC_LEGACY */
#ifdef __GNUC_STDC_INLINE__
/* Use of 'extern inline' force an emit of inline code at a symbol */
extern inline free_magic1_t freeMagic1_init(void);
extern inline void freeMagic1(free_magic1_t* m1, void* ptr);
extern inline void freeMagic1_end(free_magic1_t* m1);
#else /* __GNUC_STDC_INLINE__ */
/*
* NOTICE: non-inline form of emitted functions, keep in sync with malloc.h
*/
free_magic1_t freeMagic1_init(void) {
return NULL;
}
void freeMagic1(free_magic1_t* m1, void* ptr) {
//if(*m1) /* this if() is here to help inliner remove the call to free() when it can */
/* this is not the inline form here so if() is commented out */
{
#if (defined(SUPPORT_DIRECT_MALLOC) || defined(SUPPORT_REMOVE_MALLOC_LEGACY))
free(*m1); /* no need for NULL check with free() */
#else
/* but freeMagicLegacy() does not like NULL passed, so extra if() penalty here */
if(*m1) freeMagicLegacy(*m1);
#endif
}
*m1 = ptr;
}
void freeMagic1_end(free_magic1_t* m1) {
//if(*m1) /* this if() is here to help inliner remove the call to free() when it can */
/* this is not the inline form here so if() is commented out */
{
#if (defined(SUPPORT_DIRECT_MALLOC) || defined(SUPPORT_REMOVE_MALLOC_LEGACY))
free(*m1); /* no need for NULL check with free() */
#else
/* but freeMagicLegacy() does not like NULL passed, so extra if() penalty here */
if(*m1) freeMagicLegacy(*m1);
#endif
}
}
#endif /* __GNUC_STDC_INLINE__ */

View File

@ -22,8 +22,74 @@
#ifndef _MAGIC__UTILS__MALLOC_H #ifndef _MAGIC__UTILS__MALLOC_H
#define _MAGIC__UTILS__MALLOC_H #define _MAGIC__UTILS__MALLOC_H
extern void *mallocMagic(size_t); #include <stdlib.h>
extern void *callocMagic(size_t);
extern void freeMagic(void *);
/* build time configuration check */
#if (!defined(SUPPORT_DIRECT_MALLOC) && defined(SUPPORT_REMOVE_MALLOC_LEGACY))
#error "ERROR: Unspported build configuration SUPPORT_REMOVE_MALLOC_LEGACY is defined but SUPPORT_DIRECT_MALLOC is undefined"
#endif
#ifdef SUPPORT_DIRECT_MALLOC
#define mallocMagic malloc
#define callocMagic calloc
#define freeMagic free
#else /* SUPPORT_DIRECT_MALLOC */
extern void *mallocMagicLegacy(size_t);
#define mallocMagic(size) mallocMagicLegacy(size)
/* renamed like this, so there is no performance loss if the byte count
* can be computed at compile time.
*/
extern void *callocMagicLegacy(size_t);
#define callocMagic(nmemb, size) callocMagicLegacy((nmemb) * (size))
extern void freeMagicLegacy(void *);
#define freeMagic(ptr) freeMagicLegacy(ptr)
#endif /* SUPPORT_DIRECT_MALLOC */
typedef void* free_magic1_t;
#ifdef __GNUC_STDC_INLINE__
/* Provide compiler visibility of STDC 'inline' semantics */
/*
* NOTICE: inline form, keep in sync with malloc.c copied
*/
inline free_magic1_t freeMagic1_init(void) {
return NULL;
}
inline void freeMagic1(free_magic1_t* m1, void* ptr) {
if(*m1) /* this if() is here to help inliner remove the call to free() when it can */
{
#if (defined(SUPPORT_DIRECT_MALLOC) || defined(SUPPORT_REMOVE_MALLOC_LEGACY))
free(*m1); /* no need for NULL check with free() */
#else
freeMagicLegacy(*m1);
#endif
}
*m1 = ptr;
}
inline void freeMagic1_end(free_magic1_t* m1) {
if(*m1) /* this if() is here to help inliner remove the call to free() when it can */
{
#if (defined(SUPPORT_DIRECT_MALLOC) || defined(SUPPORT_REMOVE_MALLOC_LEGACY))
free(*m1); /* no need for NULL check with free() */
#else
freeMagicLegacy(*m1);
#endif
}
}
#else /* __GNUC_STDC_INLINE__ */
/* To support older compilers (that don't auto emit based on -O level) */
extern free_magic1_t freeMagic1_init(void);
extern void freeMagic1(free_magic1_t* m1, void* ptr);
extern void freeMagic1_end(free_magic1_t* m1);
#endif /* __GNUC_STDC_INLINE__ */
#endif /* _MAGIC__UTILS__MALLOC_H */ #endif /* _MAGIC__UTILS__MALLOC_H */

View File

@ -268,16 +268,18 @@ NLFree(netList)
NLTerm *term; NLTerm *term;
NLNet *net; NLNet *net;
free_magic1_t mm1 = freeMagic1_init();
for (net = netList->nnl_nets; net; net = net->nnet_next) for (net = netList->nnl_nets; net; net = net->nnet_next)
{ {
for (term = net->nnet_terms; term; term = term->nterm_next) for (term = net->nnet_terms; term; term = term->nterm_next)
{ {
for (loc = term->nterm_locs; loc; loc = loc->nloc_next) for (loc = term->nterm_locs; loc; loc = loc->nloc_next)
freeMagic((char *) loc); freeMagic1(&mm1, (char *) loc);
freeMagic((char *) term); freeMagic1(&mm1, (char *) term);
} }
freeMagic((char *) net); freeMagic1(&mm1, (char *) net);
} }
freeMagic1_end(&mm1);
HashKill(&netList->nnl_names); HashKill(&netList->nnl_names);
} }

View File

@ -83,12 +83,14 @@ PaVisitFree(pv)
{ {
PaVisitClient *pvc; PaVisitClient *pvc;
free_magic1_t mm1 = freeMagic1_init();
for (pvc = pv->pv_first; pvc; pvc = pvc->pvc_next) for (pvc = pv->pv_first; pvc; pvc = pvc->pvc_next)
{ {
if (pvc->pvc_keyword) if (pvc->pvc_keyword)
freeMagic(pvc->pvc_keyword); freeMagic(pvc->pvc_keyword);
freeMagic((char *) pvc); freeMagic1(&mm1, (char *) pvc);
} }
freeMagic1_end(&mm1);
freeMagic((char *) pv); freeMagic((char *) pv);
} }

View File

@ -760,8 +760,10 @@ skipsection:
{ {
fclose(fstack->file); fclose(fstack->file);
freeMagic(fstack->filename); freeMagic(fstack->filename);
freeMagic(fstack); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, fstack);
fstack = fstack->next; fstack = fstack->next;
freeMagic1_end(&mm1);
} }
if (fstack) fclose(fstack->file); if (fstack) fclose(fstack->file);

View File

@ -244,11 +244,13 @@ UndoInit(logFileName, mode)
* Deallocate any events stored in main memory * Deallocate any events stored in main memory
*/ */
while (undoLogHead != (internalUndoEvent *) NULL) free_magic1_t mm1 = freeMagic1_init();
while (undoLogHead != (internalUndoEvent *) NULL)
{ {
freeMagic((char *) undoLogHead); freeMagic1(&mm1, (char *) undoLogHead);
undoLogHead = undoLogHead->iue_forw; undoLogHead = undoLogHead->iue_forw;
} }
freeMagic1_end(&mm1);
return (TRUE); return (TRUE);
} }
@ -370,12 +372,14 @@ UndoFlush()
if (undoLogHead == (internalUndoEvent *) NULL) if (undoLogHead == (internalUndoEvent *) NULL)
return; return;
free_magic1_t mm1 = freeMagic1_init();
while (undoLogTail != undoLogHead) while (undoLogTail != undoLogHead)
{ {
freeMagic((char *) undoLogTail); freeMagic1(&mm1, (char *) undoLogTail);
undoLogTail = undoLogTail->iue_back; undoLogTail = undoLogTail->iue_back;
ASSERT(undoLogTail != (internalUndoEvent *) NULL, "UndoFlush"); ASSERT(undoLogTail != (internalUndoEvent *) NULL, "UndoFlush");
} }
freeMagic1_end(&mm1);
freeMagic((char *) undoLogHead); freeMagic((char *) undoLogHead);
undoLogHead = undoLogTail = undoLogCur = (internalUndoEvent *) NULL; undoLogHead = undoLogTail = undoLogCur = (internalUndoEvent *) NULL;
@ -813,18 +817,22 @@ undoFreeHead()
while (undoNumCommands > LOWCOMMANDS) while (undoNumCommands > LOWCOMMANDS)
{ {
free_magic1_t mm1 = freeMagic1_init();
do do
{ {
ASSERT(undoLogHead != undoLogCur, "undoFreeHead"); ASSERT(undoLogHead != undoLogCur, "undoFreeHead");
freeMagic((char *) undoLogHead); freeMagic1(&mm1, (char *) undoLogHead);
undoLogHead = undoLogHead->iue_forw; undoLogHead = undoLogHead->iue_forw;
ASSERT(undoLogHead != (internalUndoEvent *) NULL, "undoFreeHead"); ASSERT(undoLogHead != (internalUndoEvent *) NULL, "undoFreeHead");
} }
while (undoLogHead->iue_type != UT_DELIM); while (undoLogHead->iue_type != UT_DELIM);
freeMagic1_end(&mm1);
undoNumCommands--; undoNumCommands--;
} }
freeMagic((char *) undoLogHead); free_magic1_t mm1 = freeMagic1_init();
freeMagic1(&mm1, (char *) undoLogHead);
undoLogHead = undoLogHead->iue_forw; undoLogHead = undoLogHead->iue_forw;
freeMagic1_end(&mm1);
undoLogHead->iue_back = (internalUndoEvent *) NULL; undoLogHead->iue_back = (internalUndoEvent *) NULL;
} }
@ -864,11 +872,13 @@ undoMemTruncate()
* Delete ALL events from memory * Delete ALL events from memory
*/ */
up = undoLogHead; up = undoLogHead;
free_magic1_t mm1 = freeMagic1_init();
while (up != (internalUndoEvent *) NULL) while (up != (internalUndoEvent *) NULL)
{ {
freeMagic((char *) up); freeMagic1(&mm1, (char *) up);
up = up->iue_forw; up = up->iue_forw;
} }
freeMagic1_end(&mm1);
undoLogTail = undoLogHead = (internalUndoEvent *) NULL; undoLogTail = undoLogHead = (internalUndoEvent *) NULL;
undoNumCommands = 0; undoNumCommands = 0;
} }
@ -879,13 +889,15 @@ undoMemTruncate()
* Delete only some of the events in main memory. * Delete only some of the events in main memory.
*/ */
up = undoLogCur->iue_forw; up = undoLogCur->iue_forw;
free_magic1_t mm1 = freeMagic1_init();
while (up != (internalUndoEvent *) NULL) while (up != (internalUndoEvent *) NULL)
{ {
if (up->iue_type == UT_DELIM) if (up->iue_type == UT_DELIM)
undoNumCommands--; undoNumCommands--;
freeMagic((char *) up); freeMagic1(&mm1, (char *) up);
up = up->iue_forw; up = up->iue_forw;
} }
freeMagic1_end(&mm1);
undoLogCur->iue_forw = (internalUndoEvent *) NULL; undoLogCur->iue_forw = (internalUndoEvent *) NULL;
undoLogTail = undoLogCur; undoLogTail = undoLogCur;
} }

View File

@ -61,11 +61,13 @@ WireTechInit(void)
Contact *contact; Contact *contact;
int i; int i;
free_magic1_t mm1 = freeMagic1_init();
while (WireContacts != NULL) while (WireContacts != NULL)
{ {
freeMagic((char *) WireContacts); freeMagic1(&mm1, (char *) WireContacts);
WireContacts = WireContacts->con_next; WireContacts = WireContacts->con_next;
} }
freeMagic1_end(&mm1);
WireUnits = 1; WireUnits = 1;
} }