Corrected a bad error from a few commits ago, probably 198, which

can deallocate the cell name and causes all sorts of unexpected and
unwanted behavior.
This commit is contained in:
Tim Edwards 2020-03-21 12:40:35 -04:00
parent fe8e229920
commit 276bf1d78a
19 changed files with 41 additions and 44 deletions

View File

@ -1 +1 @@
8.2.199
8.2.200

View File

@ -1048,7 +1048,7 @@ calmaFindCell(name, was_called)
def = DBCellLookDef(name);
if (def == NULL)
{
def = DBCellNewDef(name, (char *) NULL);
def = DBCellNewDef(name);
/*
* Tricky point: call DBReComputeBbox here to make SURE

View File

@ -1416,7 +1416,7 @@ calmaGetContactCell(type, lookOnly)
def = DBCellLookDef(contactCellName);
if ((def == (CellDef *) NULL) && (lookOnly == FALSE))
{
def = DBCellNewDef(contactCellName, (char *) NULL);
def = DBCellNewDef(contactCellName);
def->cd_flags &= ~(CDMODIFIED|CDGETNEWSTAMP);
def->cd_flags |= CDAVAILABLE;
}

View File

@ -112,7 +112,7 @@ CIFInitCells()
CIFTotalDef = DBCellLookDef("__CIF__");
if (CIFTotalDef == (CellDef *) NULL)
{
CIFTotalDef = DBCellNewDef ("__CIF__",(char *) NULL);
CIFTotalDef = DBCellNewDef("__CIF__");
ASSERT(CIFTotalDef != (CellDef *) NULL, "cifMakeCell");
DBCellSetAvail(CIFTotalDef);
CIFTotalDef->cd_flags |= CDINTERNAL;
@ -124,7 +124,7 @@ CIFInitCells()
CIFComponentDef = DBCellLookDef("__CIF2__");
if (CIFComponentDef == (CellDef *) NULL)
{
CIFComponentDef = DBCellNewDef ("__CIF2__",(char *) NULL);
CIFComponentDef = DBCellNewDef("__CIF2__");
ASSERT(CIFComponentDef != (CellDef *) NULL, "cifMakeCell");
DBCellSetAvail(CIFComponentDef);
CIFComponentDef->cd_flags |= CDINTERNAL;

View File

@ -273,7 +273,7 @@ cifFindCell(cifNum)
def = DBCellLookDef(name);
if (def == NULL)
{
def = DBCellNewDef(name, (char *) NULL);
def = DBCellNewDef(name);
/* Tricky point: call DBReComputeBbox here to make SURE
* that the cell has a valid bounding box. Otherwise,

View File

@ -896,14 +896,12 @@ CmdCellname(w, cmd)
{
char *fullpath;
fullpath = (char *)mallocMagic(strlen(filepath) +
strlen(cellDef->cd_name) + 6);
sprintf(fullpath, "%s/%s.mag", filepath, cellDef->cd_name);
strlen(cellDef->cd_name) + 2);
sprintf(fullpath, "%s/%s", filepath, cellDef->cd_name);
if (cellDef->cd_file != NULL)
{
freeMagic(cellDef->cd_file);
cellDef->cd_file = NULL;
}
cellDef->cd_file = fullpath;
}
}
@ -945,7 +943,7 @@ CmdCellname(w, cmd)
newDef = DBCellLookDef(cellname);
if (newDef == (CellDef *) NULL)
{
newDef = DBCellNewDef(cellname, (char *) NULL);
newDef = DBCellNewDef(cellname);
DBCellSetAvail(newDef);
}
break;
@ -1442,7 +1440,7 @@ CmdCif(w, cmd)
paintDef = DBCellLookDef(argv[4]);
if (paintDef == (CellDef *)NULL)
{
paintDef = DBCellNewDef(argv[4], (char *)NULL);
paintDef = DBCellNewDef(argv[4]);
DBCellSetAvail(paintDef);
}
}
@ -3699,8 +3697,7 @@ cmdDumpParseArgs(cmdName, w, cmd, dummy, scx)
if ((cellnameptr = strrchr(cmd->tx_argv[1], '/')) != NULL)
{
cellnameptr++;
/* Allocate extra space for cellname in case it needs an extension */
fullpathname = (char *)mallocMagic(strlen(cmd->tx_argv[1]) + 10);
fullpathname = (char *)mallocMagic(strlen(cmd->tx_argv[1]) + 2);
strcpy(fullpathname, cmd->tx_argv[1]);
}
else
@ -3723,7 +3720,7 @@ cmdDumpParseArgs(cmdName, w, cmd, dummy, scx)
def = DBCellLookDef(cellnameptr);
if (def == (CellDef *) NULL)
def = DBCellNewDef(cellnameptr, (char *) NULL);
def = DBCellNewDef(cellnameptr);
if (fullpathname != NULL)
{
@ -3749,7 +3746,7 @@ cmdDumpParseArgs(cmdName, w, cmd, dummy, scx)
uniqchar++;
}
TxError("Renaming cell to \"%s\" to avoid conflict.", newcellname);
def = DBCellNewDef(cellnameptr, (char *)NULL);
def = DBCellNewDef(cellnameptr);
def->cd_file = StrDup(&def->cd_file, fullpathname);
freeMagic(newcellname);
}
@ -3777,7 +3774,7 @@ cmdDumpParseArgs(cmdName, w, cmd, dummy, scx)
dummy->cu_expandMask = CU_DESCEND_SPECIAL;
if (DBIsAncestor(def, EditCellUse->cu_def))
{
TxError("The edit cell is already a desecendant of \"%s\",\n",
TxError("The edit cell is already a descendant of \"%s\",\n",
cmd->tx_argv[1]);
TxError(" which means that you're trying to create a circular\n");
TxError(" structure. This isn't legal.\n");

View File

@ -1943,7 +1943,7 @@ CmdFlatten(w, cmd)
TxError("%s already exists\n",destname);
return;
}
newdef = DBCellNewDef(destname, (char *) NULL);
newdef = DBCellNewDef(destname);
ASSERT(newdef, "CmdFlatten");
DBCellSetAvail(newdef);
newuse = DBCellNewUse(newdef, (char *) NULL);

View File

@ -665,7 +665,7 @@ cmdSaveCell(cellDef, newName, noninteractive, tryRename)
}
cleanup:
if (fileName != newName)
if ((fileName != newName) && (fileName != cellDef->cd_name))
freeMagic(fileName);
return;
}

View File

@ -1245,14 +1245,12 @@ DBCellLookDef(cellName)
*/
CellDef *
DBCellNewDef(cellName, cellFileName)
DBCellNewDef(cellName)
char *cellName; /* Name by which the cell is known */
char *cellFileName; /* Name of disk file in which the cell
* should be kept when written out.
*/
{
CellDef *cellDef;
HashEntry *entry;
char *dotptr;
if (cellName == (char *) NULL)
cellName = UNNAMED;
@ -1264,10 +1262,12 @@ DBCellNewDef(cellName, cellFileName)
cellDef = DBCellDefAlloc();
HashSetValue(entry, (ClientData) cellDef);
cellDef->cd_name = StrDup((char **) NULL, cellName);
if (cellFileName == (char *) NULL)
cellDef->cd_file = cellFileName;
else
cellDef->cd_file = StrDup((char **) NULL, cellFileName);
/* Strip any .mag extension off of the cell name */
dotptr = strrchr(cellDef->cd_name, '.');
if (dotptr && !strcmp(dotptr, ".mag")) *dotptr = '\0';
cellDef->cd_file = NULL;
return (cellDef);
}
@ -2081,7 +2081,7 @@ DBNewYank(yname, pyuse, pydef)
*pydef = DBCellLookDef(yname);
if (*pydef == (CellDef *) NULL)
{
*pydef = DBCellNewDef (yname,(char *) NULL);
*pydef = DBCellNewDef(yname);
ASSERT(*pydef != (CellDef *) NULL, "DBNewYank");
DBCellSetAvail(*pydef);
(*pydef)->cd_flags |= CDINTERNAL;

View File

@ -859,7 +859,7 @@ DBReadBackup(name)
cellDef = DBCellLookDef(rootname);
if (cellDef == (CellDef *)NULL)
cellDef = DBCellNewDef(rootname, (char *)NULL);
cellDef = DBCellNewDef(rootname);
cellDef->cd_flags &= ~CDNOTFOUND;
cellDef->cd_flags |= CDAVAILABLE;
@ -1352,7 +1352,7 @@ badTransform:
subCellDef = DBCellLookDef(cellname);
if (subCellDef == (CellDef *) NULL)
{
subCellDef = DBCellNewDef(cellname, (char *)NULL);
subCellDef = DBCellNewDef(cellname);
subCellDef->cd_timestamp = childStamp;
/* Make sure rectangle is non-degenerate */

View File

@ -328,7 +328,7 @@ DBWloadWindow(window, name, ignoreTech, expand, dereference)
newEditDef = DBCellLookDef(UNNAMED);
if (newEditDef == (CellDef *) NULL)
{
newEditDef = DBCellNewDef(UNNAMED, (char *) NULL);
newEditDef = DBCellNewDef(UNNAMED);
DBCellSetAvail(newEditDef);
}
}
@ -397,7 +397,7 @@ DBWloadWindow(window, name, ignoreTech, expand, dereference)
}
}
if (newEditDef == (CellDef *) NULL)
newEditDef = DBCellNewDef(rootname, (char *) NULL);
newEditDef = DBCellNewDef(rootname);
if (dereference) newEditDef->cd_flags |= CDDEREFERENCE;
@ -431,7 +431,7 @@ DBWloadWindow(window, name, ignoreTech, expand, dereference)
newEditDef = DBCellLookDef(UNNAMED);
if (newEditDef == (CellDef *) NULL)
{
newEditDef = DBCellNewDef(UNNAMED, (char *) NULL);
newEditDef = DBCellNewDef(UNNAMED);
DBCellSetAvail(newEditDef);
}
}

View File

@ -345,7 +345,7 @@ DRCInit()
DRCdef = DBCellLookDef(DRCYANK);
if (DRCdef == (CellDef *) NULL)
{
DRCdef = DBCellNewDef (DRCYANK,(char *) NULL);
DRCdef = DBCellNewDef(DRCYANK);
ASSERT(DRCdef != (CellDef *) NULL, "DRCInit");
DBCellSetAvail(DRCdef);
DRCdef->cd_flags |= CDINTERNAL;

View File

@ -1541,7 +1541,7 @@ DefReadComponents(f, rootDef, sname, oscale, total)
/* Before giving up, assume that this cell has a */
/* magic .mag layout file. */
defMacro = DBCellNewDef(token, (char *)NULL);
defMacro = DBCellNewDef(token);
defMacro->cd_flags &= ~CDNOTFOUND;
dereference = (defMacro->cd_flags & CDDEREFERENCE) ? TRUE : FALSE;
if (!DBCellRead(defMacro, (char *)NULL, TRUE, dereference, NULL))

View File

@ -572,7 +572,7 @@ lefFindCell(name)
def = DBCellLookDef(name);
if (def == NULL)
{
def = DBCellNewDef(name, (char *)NULL);
def = DBCellNewDef(name);
DBReComputeBbox(def);
}
HashSetValue(h, def);

View File

@ -675,7 +675,7 @@ lefWriteMacro(def, f, scale, hide)
lefFlatDef = DBCellLookDef("__lefFlat__");
if (lefFlatDef == (CellDef *)NULL)
lefFlatDef = DBCellNewDef("__lefFlat__", (char *)NULL);
lefFlatDef = DBCellNewDef("__lefFlat__");
DBCellSetAvail(lefFlatDef);
lefFlatDef->cd_flags |= CDINTERNAL;
@ -828,7 +828,7 @@ lefWriteMacro(def, f, scale, hide)
lc.lefYank = DBCellLookDef("__lefYank__");
if (lc.lefYank == (CellDef *)NULL)
lc.lefYank = DBCellNewDef("__lefYank__", (char *)NULL);
lc.lefYank = DBCellNewDef("__lefYank__");
DBCellSetAvail(lc.lefYank);
lc.lefYank->cd_flags |= CDINTERNAL;

View File

@ -235,7 +235,7 @@ nmGetShowCell()
nmscShowDef = DBCellLookDef("__SHOW__");
if (nmscShowDef == NULL)
{
nmscShowDef = DBCellNewDef("__SHOW__", (char *) NULL);
nmscShowDef = DBCellNewDef("__SHOW__");
ASSERT (nmscShowDef != (CellDef *) NULL, "nmGetShowCell");
DBCellSetAvail(nmscShowDef);
nmscShowDef->cd_flags |= CDINTERNAL;

View File

@ -113,7 +113,7 @@ ResGetReCell()
ResDef = DBCellLookDef("__RESIS__");
if (ResDef == NULL)
{
ResDef = DBCellNewDef("__RESIS__", (char *) NULL);
ResDef = DBCellNewDef("__RESIS__");
ASSERT (ResDef != (CellDef *) NULL, "ResGetReCell");
DBCellSetAvail(ResDef);
ResDef->cd_flags |= CDINTERNAL;

View File

@ -271,7 +271,7 @@ RtrFindChannelDef()
/* Create our target cell */
if ((def = DBCellLookDef("__CHANNEL__")) == (CellDef *) NULL)
{
def = DBCellNewDef("__CHANNEL__", (char *) NULL);
def = DBCellNewDef("__CHANNEL__");
DBCellSetAvail(def);
def->cd_flags |= CDINTERNAL;
}

View File

@ -108,7 +108,7 @@ SelectInit()
SelectDef = DBCellLookDef("__SELECT__");
if (SelectDef == (CellDef *) NULL)
{
SelectDef = DBCellNewDef("__SELECT__",(char *) NULL);
SelectDef = DBCellNewDef("__SELECT__");
ASSERT(SelectDef != (CellDef *) NULL, "SelectInit");
DBCellSetAvail(SelectDef);
SelectDef->cd_flags |= CDINTERNAL;
@ -122,7 +122,7 @@ SelectInit()
Select2Def = DBCellLookDef("__SELECT2__");
if (Select2Def == (CellDef *) NULL)
{
Select2Def = DBCellNewDef("__SELECT2__",(char *) NULL);
Select2Def = DBCellNewDef("__SELECT2__");
ASSERT(Select2Def != (CellDef *) NULL, "SelectInit");
DBCellSetAvail(Select2Def);
Select2Def->cd_flags |= CDINTERNAL;