From 451dab4b9beab7a32fb3c38af6c3356f54f1060d Mon Sep 17 00:00:00 2001 From: "Darryl L. Miles" Date: Sat, 4 Jan 2025 09:05:56 +0000 Subject: [PATCH] lef: constify strings in data structures of lef module --- lef/defRead.c | 2 +- lef/defWrite.c | 22 ++++++++++++---------- lef/lefInt.h | 8 ++++---- lef/lefRead.c | 14 +++++++------- lef/lefTech.c | 2 +- lef/lefWrite.c | 4 ++-- 6 files changed, 27 insertions(+), 25 deletions(-) diff --git a/lef/defRead.c b/lef/defRead.c index 16265a92..c135afd0 100644 --- a/lef/defRead.c +++ b/lef/defRead.c @@ -1960,7 +1960,7 @@ DefReadVias( lefl->info.via.cell = (CellDef *)NULL; lefl->info.via.lr = (LinkedRect *)NULL; HashSetValue(he, lefl); - lefl->canonName = (char *)he->h_key.h_name; + lefl->canonName = (const char *)he->h_key.h_name; } else { diff --git a/lef/defWrite.c b/lef/defWrite.c index e3309287..d2b40bb0 100644 --- a/lef/defWrite.c +++ b/lef/defWrite.c @@ -62,7 +62,7 @@ typedef struct { typedef struct { CellDef *def; int nlayers; - char **baseNames; + const char **baseNames; TileTypeBitMask *blockMasks; LinkedRect **blockData; } DefObsData; @@ -79,7 +79,7 @@ typedef struct { /*----------------------------------------------------------------------*/ -char *defGetType(TileType ttype, lefLayer **lefptr, bool do_vias); /* Forward declaration */ +const char *defGetType(TileType ttype, lefLayer **lefptr, bool do_vias); /* Forward declaration */ /*----------------------------------------------------------------------*/ @@ -934,7 +934,8 @@ defNetGeometryFunc( int routeWidth, w, h, midlinex2, topClip, botClip; float x1, y1, x2, y2, extlen; lefLayer *lefType, *lefl; - char *lefName, viaName[128], posstr[24]; + const char *lefName; + char viaName[128], posstr[24]; LefRules *lastruleset = defdata->ruleset; HashEntry *he; HashTable *defViaTable = defdata->defViaTable; @@ -1456,7 +1457,7 @@ defNetGeometryFunc( if (orient == GEO_CENTER) { - char *rName; + const char *rName; /* Type can be zero (space) if the first tile */ /* encountered is a via. If so, use the 1st */ @@ -1712,7 +1713,8 @@ defCountViaFunc( TileType ttype = TiGetType(tile), ctype, rtype; TileTypeBitMask *rmask, *rmask2; Tile *tp; - char *lname, vname[100], posstr[24]; + const char *lname; + char vname[100], posstr[24]; Rect r, r2, rorig; int w, h, offx, offy, sdist, lorient, horient; int ldist, hdist, sldist, shdist, pNum; @@ -1933,7 +1935,7 @@ defCountViaFunc( lefl->info.via.lr = (LinkedRect *)NULL; lefl->refCnt = 0; /* These entries will be removed after writing */ HashSetValue(he, lefl); - lefl->canonName = (char *)he->h_key.h_name; + lefl->canonName = (const char *)he->h_key.h_name; if ((sldist > 0) || (ldist > 0)) { @@ -2015,7 +2017,7 @@ defCountViaFunc( *------------------------------------------------------------ */ -char * +const char * defGetType( TileType ttype, lefLayer **lefptr, @@ -2100,7 +2102,7 @@ defWriteVias( while ((he = HashNext(&LefInfo, &hs))) { int size, sep, border; - char *us1, *us2; + const char *us1, *us2; lefl = (lefLayer *)HashGetValue(he); if (!lefl) continue; @@ -2497,7 +2499,7 @@ defWriteBlockages( if ((lefl != NULL) && ((lefl->lefClass == CLASS_ROUTE) || (lefl->lefClass == CLASS_VIA))) { - char *llayer; + const char *llayer; if (lefl->lefClass == CLASS_ROUTE) llayer = lefl->canonName; else @@ -2876,7 +2878,7 @@ defMakeInverseLayerMap( LefMapping *lefMagicToLefLayer; lefLayer *lefl; TileType i; - char *lefname; + const char *lefname; lefMagicToLefLayer = (LefMapping *)mallocMagic(DBNumTypes * sizeof(LefMapping)); diff --git a/lef/lefInt.h b/lef/lefInt.h index 16060b33..839a34ea 100644 --- a/lef/lefInt.h +++ b/lef/lefInt.h @@ -85,7 +85,7 @@ typedef struct { TileType type; /* magic tile type, or -1 for none */ TileType obsType; /* magic type to use if this is an obstruction */ short refCnt; /* reference count for memory deallocation */ - char * canonName; /* name to use when writing LEF output */ + const char * canonName; /* name to use when writing LEF output */ unsigned char lefClass; /* is this a via, route, or masterslice layer */ union { lefRoute route; /* for route layers */ @@ -97,7 +97,7 @@ typedef struct { /* layer corresponding to a magic tile type. */ typedef struct { - char *lefName; /* Primary name of LEF layer */ + const char *lefName; /* Primary name of LEF layer */ lefLayer *lefInfo; /* Pointer to information about the layer */ } LefMapping; @@ -114,7 +114,7 @@ typedef struct _lefRule { /* Structure to hold nondefault rules required by nets */ typedef struct { - char *name; + const char *name; lefRule *rule; } LefRules; @@ -129,7 +129,7 @@ typedef struct { /* Linked string structure used to maintain list of nets to ignore */ typedef struct _linkedNetName { - char *lnn_name; + const char *lnn_name; struct _linkedNetName *lnn_next; } linkedNetName; diff --git a/lef/lefRead.c b/lef/lefRead.c index eae676fc..2b8acdff 100644 --- a/lef/lefRead.c +++ b/lef/lefRead.c @@ -639,7 +639,7 @@ LefRedefined( const char *redefname) { lefLayer *slef, *newlefl; - char *altName; + const char *altName; LinkedRect *viaLR; HashSearch hs; HashEntry *he; @@ -659,8 +659,8 @@ LefRedefined( if (slef == lefl) records++; if (altName == NULL) - if (strcmp((char *)he->h_key.h_name, redefname)) - altName = (char *)he->h_key.h_name; + if (strcmp((const char *)he->h_key.h_name, redefname)) + altName = (const char *)he->h_key.h_name; } if (records == 1) { @@ -676,7 +676,7 @@ LefRedefined( he = HashFind(&LefInfo, redefname); newlefl = (lefLayer *)mallocMagic(sizeof(lefLayer)); newlefl->refCnt = 1; - newlefl->canonName = (char *)he->h_key.h_name; + newlefl->canonName = (const char *)he->h_key.h_name; HashSetValue(he, newlefl); /* If the canonical name of the original entry */ @@ -1960,7 +1960,7 @@ LefReadNonDefaultRule( lefl->info.via.lr = (LinkedRect *)NULL; HashSetValue(he, lefl); LefReadLayerSection(f, tsave, keyword, lefl); - lefl->canonName = (char *)he->h_key.h_name; + lefl->canonName = (const char *)he->h_key.h_name; } goto newrule; @@ -3007,7 +3007,7 @@ LefRead( lefl->info.via.lr = (LinkedRect *)NULL; HashSetValue(he, lefl); LefReadLayerSection(f, tsave, keyword, lefl); - lefl->canonName = (char *)he->h_key.h_name; + lefl->canonName = (const char *)he->h_key.h_name; } else if (keyword == LEF_SECTION_VIARULE) /* If we've already seen this via, don't reprocess. */ @@ -3064,7 +3064,7 @@ LefRead( lefl->refCnt = 1; lefl->lefClass = (DBIsContact(mtype)) ? CLASS_VIA : CLASS_ROUTE; HashSetValue(he, lefl); - lefl->canonName = (char *)he->h_key.h_name; + lefl->canonName = (const char *)he->h_key.h_name; } } else diff --git a/lef/lefTech.c b/lef/lefTech.c index 36dabcb1..509e46eb 100644 --- a/lef/lefTech.c +++ b/lef/lefTech.c @@ -317,7 +317,7 @@ LefTechLine( else newlefl->type = mtype; } - newlefl->canonName = (char *)he->h_key.h_name; + newlefl->canonName = (const char *)he->h_key.h_name; /* "isObstruction" records whether the type is an */ /* obstruction or not. So recast the option to a route */ diff --git a/lef/lefWrite.c b/lef/lefWrite.c index 6d102d1f..195d1423 100644 --- a/lef/lefWrite.c +++ b/lef/lefWrite.c @@ -308,7 +308,7 @@ lefWriteHeader( /* NOTE: Type (e.g., "STRING") may be kept in hash value. */ /* This has not been implemented; only string types are supported */ - fprintf(f, IN0 "MACRO %s STRING ;\n", (char *)he->h_key.h_name); + fprintf(f, IN0 "MACRO %s STRING ;\n", (const char *)he->h_key.h_name); } if (nprops > 0) fprintf(f, "END PROPERTYDEFINITIONS\n\n"); @@ -323,7 +323,7 @@ lefWriteHeader( char *propvalue; Rect boundary; - siteDef = DBCellLookDef((char *)he->h_key.h_name); + siteDef = DBCellLookDef((const char *)he->h_key.h_name); if (siteDef) { fprintf(f, "SITE %s\n", siteDef->cd_name);