calma: use 'const' with readonly data
This then required a cascade of function APIs to also now receive const arguments. This reduces the .data segment use of this module.
This commit is contained in:
parent
378755e083
commit
4cd1235575
|
|
@ -350,7 +350,7 @@ bool
|
|||
calmaParseStructure(
|
||||
char *filename) /* Name of the GDS file read */
|
||||
{
|
||||
static int structs[] = { CALMA_STRCLASS, CALMA_STRTYPE, -1 };
|
||||
static const int structs[] = { CALMA_STRCLASS, CALMA_STRTYPE, -1 };
|
||||
int nbytes = -1, rtype = 0, nsrefs, osrefs, npaths;
|
||||
char *strname = NULL;
|
||||
HashEntry *he;
|
||||
|
|
@ -680,7 +680,7 @@ calmaParseElement(
|
|||
int *pnsrefs,
|
||||
int *pnpaths)
|
||||
{
|
||||
static int node[] = { CALMA_ELFLAGS, CALMA_PLEX, CALMA_LAYER,
|
||||
static const int node[] = { CALMA_ELFLAGS, CALMA_PLEX, CALMA_LAYER,
|
||||
CALMA_NODETYPE, CALMA_XY, -1 };
|
||||
int nbytes, rtype, madeinst;
|
||||
|
||||
|
|
@ -1351,7 +1351,7 @@ calmaUniqueCell(
|
|||
|
||||
CellDef *
|
||||
calmaFindCell(
|
||||
char *name, /* Name of desired cell */
|
||||
const char *name, /* Name of desired cell */
|
||||
bool *was_called, /* If this cell is in the hash table, then it
|
||||
* was instanced before it was defined. We
|
||||
* need to know this so as to avoid flattening
|
||||
|
|
|
|||
|
|
@ -490,9 +490,9 @@ calmaReadR8(
|
|||
|
||||
void
|
||||
calmaSkipSet(
|
||||
int *skipwhat)
|
||||
const int *skipwhat)
|
||||
{
|
||||
int *skipp;
|
||||
const int *skipp;
|
||||
int nbytes, rtype;
|
||||
|
||||
for (;;)
|
||||
|
|
|
|||
|
|
@ -732,7 +732,7 @@ calmaElementPath(void)
|
|||
void
|
||||
calmaElementText(void)
|
||||
{
|
||||
static int ignore[] = { CALMA_PATHTYPE, CALMA_WIDTH, -1 };
|
||||
static const int ignore[] = { CALMA_PATHTYPE, CALMA_WIDTH, -1 };
|
||||
char *textbody = NULL;
|
||||
int nbytes = -1, rtype = 0;
|
||||
int layer, textt, cifnum, textpres;
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ HashTable calmaLayerHash;
|
|||
HashTable calmaDefInitHash;
|
||||
|
||||
/* Common stuff to ignore */
|
||||
int calmaElementIgnore[] = { CALMA_ELFLAGS, CALMA_PLEX, -1 };
|
||||
const int calmaElementIgnore[] = { CALMA_ELFLAGS, CALMA_PLEX, -1 };
|
||||
|
||||
/*
|
||||
* ----------------------------------------------------------------------------
|
||||
|
|
@ -174,10 +174,10 @@ CalmaReadFile(
|
|||
int k, version;
|
||||
char *libname = NULL, *libnameptr = NULL;
|
||||
MagWindow *mw;
|
||||
static int hdrSkip[] = { CALMA_FORMAT, CALMA_MASK, CALMA_ENDMASKS,
|
||||
static const int hdrSkip[] = { CALMA_FORMAT, CALMA_MASK, CALMA_ENDMASKS,
|
||||
CALMA_REFLIBS, CALMA_FONTS, CALMA_ATTRTABLE,
|
||||
CALMA_STYPTABLE, CALMA_GENERATIONS, -1 };
|
||||
static int skipBeforeLib[] = { CALMA_LIBDIRSIZE, CALMA_SRFNAME,
|
||||
static const int skipBeforeLib[] = { CALMA_LIBDIRSIZE, CALMA_SRFNAME,
|
||||
CALMA_LIBSECUR, -1 };
|
||||
|
||||
if (EditCellUse == (CellUse *)NULL)
|
||||
|
|
@ -558,12 +558,12 @@ calmaUnexpected(
|
|||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
char *
|
||||
const char *
|
||||
calmaRecordName(
|
||||
int rtype)
|
||||
{
|
||||
static char numeric[10];
|
||||
static char *calmaRecordNames[] =
|
||||
static const char * const calmaRecordNames[] =
|
||||
{
|
||||
"HEADER", "BGNLIB", "LIBNAME", "UNITS",
|
||||
"ENDLIB", "BGNSTR", "STRNAME", "ENDSTR",
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ extern void calmaWriteLabelFunc(Label *lab, int ltype, int type, FILE *f);
|
|||
extern void calmaOutHeader(CellDef *rootDef, FILE *f);
|
||||
extern void calmaOutDate(time_t t, FILE *f);
|
||||
extern void calmaOutStringRecord(int type, char *str, FILE *f);
|
||||
extern void calmaOut8(char *str, FILE *f);
|
||||
extern void calmaOut8(const char *str, FILE *f);
|
||||
extern void calmaOutR8(double d, FILE *f);
|
||||
extern void calmaProcessBoundary(BoundaryTop *blist, calmaOutputStruct *cos);
|
||||
extern void calmaRemoveColinear(BoundaryTop *blist);
|
||||
|
|
@ -199,7 +199,7 @@ HashTable calmaUndefHash;
|
|||
(void) putc(u.u_c[3], f); \
|
||||
}
|
||||
|
||||
static char calmaMapTableStrict[] =
|
||||
static const char calmaMapTableStrict[] =
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* NUL - BEL */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* BS - SI */
|
||||
|
|
@ -219,7 +219,7 @@ static char calmaMapTableStrict[] =
|
|||
'x', 'y', 'z', '_', '_', '_', '_', 0, /* x - DEL */
|
||||
};
|
||||
|
||||
static char calmaMapTablePermissive[] =
|
||||
static const char calmaMapTablePermissive[] =
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* NUL - BEL */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* BS - SI */
|
||||
|
|
@ -686,10 +686,10 @@ calmaFullDump(
|
|||
HashSearch hs;
|
||||
HashEntry *he, *he2;
|
||||
|
||||
static int hdrSkip[] = { CALMA_FORMAT, CALMA_MASK, CALMA_ENDMASKS,
|
||||
static const int hdrSkip[] = { CALMA_FORMAT, CALMA_MASK, CALMA_ENDMASKS,
|
||||
CALMA_REFLIBS, CALMA_FONTS, CALMA_ATTRTABLE,
|
||||
CALMA_STYPTABLE, CALMA_GENERATIONS, -1 };
|
||||
static int skipBeforeLib[] = { CALMA_LIBDIRSIZE, CALMA_SRFNAME,
|
||||
static const int skipBeforeLib[] = { CALMA_LIBDIRSIZE, CALMA_SRFNAME,
|
||||
CALMA_LIBSECUR, -1 };
|
||||
|
||||
HashInit(&calmaDefHash, 32, 0);
|
||||
|
|
@ -1524,10 +1524,10 @@ calmaWriteUseFunc(
|
|||
* only 4 possible values, it is faster to have them pre-computed
|
||||
* than to format with calmaOutR8().
|
||||
*/
|
||||
static unsigned char r90[] = { 0x42, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
static unsigned char r180[] = { 0x42, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
static unsigned char r270[] = { 0x43, 0x10, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
unsigned char *whichangle;
|
||||
static const unsigned char r90[] = { 0x42, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
static const unsigned char r180[] = { 0x42, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
static const unsigned char r270[] = { 0x43, 0x10, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
const unsigned char *whichangle;
|
||||
int x, y, topx, topy, rows, cols, xxlate, yxlate, hdrsize;
|
||||
int rectype, stransflags;
|
||||
Transform *t;
|
||||
|
|
@ -1738,7 +1738,7 @@ calmaOutStructName(
|
|||
unsigned char c;
|
||||
char *cp;
|
||||
int calmanum;
|
||||
char *table;
|
||||
const char *table;
|
||||
|
||||
if (CIFCurStyle->cs_flags & CWF_PERMISSIVE_LABELS)
|
||||
{
|
||||
|
|
@ -3245,7 +3245,8 @@ calmaOutStringRecord(
|
|||
{
|
||||
int len;
|
||||
unsigned char c;
|
||||
char *table, *locstr, *origstr = NULL;
|
||||
const char *table;
|
||||
char *locstr, *origstr = NULL;
|
||||
char *locstrprv; /* Added by BSI */
|
||||
|
||||
if(CIFCurStyle->cs_flags & CWF_PERMISSIVE_LABELS)
|
||||
|
|
@ -3415,7 +3416,7 @@ calmaOutR8(
|
|||
|
||||
void
|
||||
calmaOut8(
|
||||
char *str, /* 8-byte string to be output */
|
||||
const char *str, /* 8-byte string to be output */
|
||||
FILE *f) /* Stream file */
|
||||
{
|
||||
int i;
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ extern void calmaWriteLabelFuncZ(Label *lab, int ltype, int type, gzFile f);
|
|||
extern void calmaOutHeaderZ(CellDef *rootDef, gzFile f);
|
||||
extern void calmaOutDateZ(time_t t, gzFile f);
|
||||
extern void calmaOutStringRecordZ(int type, char *str, gzFile f);
|
||||
extern void calmaOut8Z(char *str, gzFile f);
|
||||
extern void calmaOut8Z(const char *str, gzFile f);
|
||||
extern void calmaOutR8Z(double d, gzFile f);
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
|
|
@ -180,7 +180,7 @@ extern void calmaOutR8Z(double d, gzFile f);
|
|||
(void) gzputc(f, u.u_c[3]); \
|
||||
}
|
||||
|
||||
static char calmaMapTableStrict[] =
|
||||
static const char calmaMapTableStrict[] =
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* NUL - BEL */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* BS - SI */
|
||||
|
|
@ -200,7 +200,7 @@ static char calmaMapTableStrict[] =
|
|||
'x', 'y', 'z', '_', '_', '_', '_', 0, /* x - DEL */
|
||||
};
|
||||
|
||||
static char calmaMapTablePermissive[] =
|
||||
static const char calmaMapTablePermissive[] =
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* NUL - BEL */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, /* BS - SI */
|
||||
|
|
@ -667,10 +667,10 @@ calmaFullDumpZ(
|
|||
HashSearch hs;
|
||||
HashEntry *he, *he2;
|
||||
|
||||
static int hdrSkip[] = { CALMA_FORMAT, CALMA_MASK, CALMA_ENDMASKS,
|
||||
static const int hdrSkip[] = { CALMA_FORMAT, CALMA_MASK, CALMA_ENDMASKS,
|
||||
CALMA_REFLIBS, CALMA_FONTS, CALMA_ATTRTABLE,
|
||||
CALMA_STYPTABLE, CALMA_GENERATIONS, -1 };
|
||||
static int skipBeforeLib[] = { CALMA_LIBDIRSIZE, CALMA_SRFNAME,
|
||||
static const int skipBeforeLib[] = { CALMA_LIBDIRSIZE, CALMA_SRFNAME,
|
||||
CALMA_LIBSECUR, -1 };
|
||||
|
||||
HashInit(&calmaDefHash, 32, 0);
|
||||
|
|
@ -1365,10 +1365,10 @@ calmaWriteUseFuncZ(
|
|||
* only 4 possible values, it is faster to have them pre-computed
|
||||
* than to format with calmaOutR8Z().
|
||||
*/
|
||||
static unsigned char r90[] = { 0x42, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
static unsigned char r180[] = { 0x42, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
static unsigned char r270[] = { 0x43, 0x10, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
unsigned char *whichangle;
|
||||
static const unsigned char r90[] = { 0x42, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
static const unsigned char r180[] = { 0x42, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
static const unsigned char r270[] = { 0x43, 0x10, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
const unsigned char *whichangle;
|
||||
int x, y, topx, topy, rows, cols, xxlate, yxlate, hdrsize;
|
||||
int rectype, stransflags;
|
||||
Transform *t;
|
||||
|
|
@ -1579,7 +1579,7 @@ calmaOutStructNameZ(
|
|||
unsigned char c;
|
||||
char *cp;
|
||||
int calmanum;
|
||||
char *table;
|
||||
const char *table;
|
||||
|
||||
if (CIFCurStyle->cs_flags & CWF_PERMISSIVE_LABELS)
|
||||
{
|
||||
|
|
@ -2638,7 +2638,8 @@ calmaOutStringRecordZ(
|
|||
{
|
||||
int len;
|
||||
unsigned char c;
|
||||
char *table, *locstr, *origstr = NULL;
|
||||
const char *table;
|
||||
char *locstr, *origstr = NULL;
|
||||
char *locstrprv;
|
||||
|
||||
if(CIFCurStyle->cs_flags & CWF_PERMISSIVE_LABELS)
|
||||
|
|
@ -2808,7 +2809,7 @@ calmaOutR8Z(
|
|||
|
||||
void
|
||||
calmaOut8Z(
|
||||
char *str, /* 8-byte string to be output */
|
||||
const char *str, /* 8-byte string to be output */
|
||||
gzFile f) /* Compressed stream file */
|
||||
{
|
||||
int i;
|
||||
|
|
|
|||
|
|
@ -226,8 +226,8 @@ typedef struct portlabel
|
|||
|
||||
/* Other commonly used globals */
|
||||
extern HashTable calmaLayerHash;
|
||||
extern int calmaElementIgnore[];
|
||||
extern CellDef *calmaFindCell(char *name, bool *was_called, bool *predefined);
|
||||
extern const int calmaElementIgnore[];
|
||||
extern CellDef *calmaFindCell(const char *name, bool *was_called, bool *predefined);
|
||||
|
||||
/* (Added by Nishit, 8/18/2004--8/24/2004) */
|
||||
extern CellDef *calmaLookCell(char *name);
|
||||
|
|
@ -235,8 +235,8 @@ extern void calmaWriteContacts(FILE *f);
|
|||
extern CellDef *calmaGetContactCell(TileType type, bool lookOnly);
|
||||
extern bool calmaIsContactCell;
|
||||
|
||||
extern char *calmaRecordName(int rtype);
|
||||
extern void calmaSkipSet(int *skipwhat);
|
||||
extern const char *calmaRecordName(int rtype);
|
||||
extern void calmaSkipSet(const int *skipwhat);
|
||||
extern bool calmaParseUnits(void);
|
||||
|
||||
extern int compport(const void *one, const void *two);
|
||||
|
|
|
|||
Loading…
Reference in New Issue