CalmaRdpt.c: simplfy use of sprintf()

This replacement pattern is easier to reason about and less error prone.
This commit is contained in:
Darryl L. Miles 2024-10-04 11:19:10 +01:00 committed by Tim Edwards
parent 46eb71491c
commit 378755e083
1 changed files with 4 additions and 4 deletions

View File

@ -257,13 +257,13 @@ calmaElementBoundary(void)
if ((CalmaSubcellPolygons != CALMA_POLYGON_NONE) && (calmaNonManhattan > 0)) if ((CalmaSubcellPolygons != CALMA_POLYGON_NONE) && (calmaNonManhattan > 0))
{ {
/* Place the polygon in its own subcell */ /* Place the polygon in its own subcell */
char newname[] = "polygonXXXXX"; char newname[16];
HashEntry *he; HashEntry *he;
savedef = cifReadCellDef; savedef = cifReadCellDef;
/* Make up name for cell */ /* Make up name for cell */
sprintf(newname + 7, "%05d", ++CalmaPolygonCount); snprintf(newname, sizeof(newname), "polygon%05d", ++CalmaPolygonCount);
he = HashFind(&calmaDefInitHash, newname); he = HashFind(&calmaDefInitHash, newname);
if (!HashGetValue(he)) if (!HashGetValue(he))
@ -663,13 +663,13 @@ calmaElementPath(void)
if (CalmaSubcellPaths) if (CalmaSubcellPaths)
{ {
/* Place the path in its own subcell */ /* Place the path in its own subcell */
char newname[] = "pathXXXXX"; char newname[16];
HashEntry *he; HashEntry *he;
savedef = cifReadCellDef; savedef = cifReadCellDef;
/* Make up name for cell */ /* Make up name for cell */
sprintf(newname + 4, "%05d", ++CalmaPathCount); snprintf(newname, sizeof(newname), "path%05d", ++CalmaPathCount);
he = HashFind(&calmaDefInitHash, newname); he = HashFind(&calmaDefInitHash, newname);
if (!HashGetValue(he)) if (!HashGetValue(he))