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); def = DBCellLookDef(name);
if (def == NULL) if (def == NULL)
{ {
def = DBCellNewDef(name, (char *) NULL); def = DBCellNewDef(name);
/* /*
* Tricky point: call DBReComputeBbox here to make SURE * Tricky point: call DBReComputeBbox here to make SURE

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -345,7 +345,7 @@ DRCInit()
DRCdef = DBCellLookDef(DRCYANK); DRCdef = DBCellLookDef(DRCYANK);
if (DRCdef == (CellDef *) NULL) if (DRCdef == (CellDef *) NULL)
{ {
DRCdef = DBCellNewDef (DRCYANK,(char *) NULL); DRCdef = DBCellNewDef(DRCYANK);
ASSERT(DRCdef != (CellDef *) NULL, "DRCInit"); ASSERT(DRCdef != (CellDef *) NULL, "DRCInit");
DBCellSetAvail(DRCdef); DBCellSetAvail(DRCdef);
DRCdef->cd_flags |= CDINTERNAL; 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 */ /* Before giving up, assume that this cell has a */
/* magic .mag layout file. */ /* magic .mag layout file. */
defMacro = DBCellNewDef(token, (char *)NULL); defMacro = DBCellNewDef(token);
defMacro->cd_flags &= ~CDNOTFOUND; defMacro->cd_flags &= ~CDNOTFOUND;
dereference = (defMacro->cd_flags & CDDEREFERENCE) ? TRUE : FALSE; dereference = (defMacro->cd_flags & CDDEREFERENCE) ? TRUE : FALSE;
if (!DBCellRead(defMacro, (char *)NULL, TRUE, dereference, NULL)) if (!DBCellRead(defMacro, (char *)NULL, TRUE, dereference, NULL))

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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