summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-10-15 13:10:52 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2022-10-15 13:10:52 -0700
commitc420f450d0a2b1f26d4043334bb8b6524fea4b07 (patch)
treec78fad4226f66e4003a2991a26d31cf11298a196
parent2900d7a7e7929414268cb142bf00c57d370e1396 (diff)
Stop casting return value of malloc() and calloc()
Not needed in C89 and later, and may hide errors Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--do_arcs.c4
-rw-r--r--do_blt.c4
-rw-r--r--do_complex.c4
-rw-r--r--do_dots.c2
-rw-r--r--do_lines.c2
-rw-r--r--do_movewin.c10
-rw-r--r--do_rects.c2
-rw-r--r--do_segs.c6
-rw-r--r--do_text.c22
-rw-r--r--do_traps.c6
-rw-r--r--do_tris.c2
-rw-r--r--do_windows.c4
-rw-r--r--x11perf.c4
13 files changed, 36 insertions, 36 deletions
diff --git a/do_arcs.c b/do_arcs.c
index ecf381f..6ab1547 100644
--- a/do_arcs.c
+++ b/do_arcs.c
@@ -45,7 +45,7 @@ GenerateCircles(XParms xp, Parms p, Bool partialArcs, Bool ddashed)
size = p->special;
half = (size + 19) / 20;
- arcs = (XArc *)malloc((p->objects) * sizeof(XArc));
+ arcs = malloc((p->objects) * sizeof(XArc));
x = xorg = half; y = yorg = half;
rows = 0;
startAngle = DegreesToX(0);
@@ -250,7 +250,7 @@ GenerateEllipses(XParms xp, Parms p, int partialArcs, Bool ddashed)
size = p->special;
half = (size + 19) / 20;
- arcs = (XArc *)malloc((p->objects) * sizeof(XArc));
+ arcs = malloc((p->objects) * sizeof(XArc));
vsize = 1;
vsizeinc = (size - 1) / (p->objects - 1);
if (vsizeinc == 0) vsizeinc = 1;
diff --git a/do_blt.c b/do_blt.c
index b44eb42..318fb03 100644
--- a/do_blt.c
+++ b/do_blt.c
@@ -149,8 +149,8 @@ InitCopyLocations(int size, int mul, int div,
x2 = width;
y2 = height;
- *ap = a = (XSegment *)malloc(reps * sizeof(XSegment));
- *bp = b = (XSegment *)malloc(reps * sizeof(XSegment));
+ *ap = a = malloc(reps * sizeof(XSegment));
+ *bp = b = malloc(reps * sizeof(XSegment));
for (int i = 0; i != reps; i++) {
a[i].x1 = x1 * div / mul;
a[i].y1 = y1 * div / mul;
diff --git a/do_complex.c b/do_complex.c
index 82a2f9d..8fcabe8 100644
--- a/do_complex.c
+++ b/do_complex.c
@@ -67,7 +67,7 @@ InitComplexPoly(XParms xp, Parms p, int64_t reps)
iradius = (int) radius + 1;
numPoints = (p->objects) * NUM_POINTS;
- points = (XPoint *)malloc(numPoints * sizeof(XPoint));
+ points = malloc(numPoints * sizeof(XPoint));
curPoint = points;
x = iradius;
y = iradius;
@@ -139,7 +139,7 @@ InitGeneralPoly(XParms xp, Parms p, int64_t reps)
inner_radius = size / sqrt (nsides * tan (PI / nsides));
outer_radius = inner_radius / cos (PI / (2 * nsides));
numPoints = p->objects * nsides;
- points = (XPoint *) malloc (numPoints * sizeof (XPoint));
+ points = malloc (numPoints * sizeof (XPoint));
curPoint = points;
iradius = outer_radius + 1;
x = iradius;
diff --git a/do_dots.c b/do_dots.c
index a02cb10..38944e0 100644
--- a/do_dots.c
+++ b/do_dots.c
@@ -31,7 +31,7 @@ InitDots(XParms xp, Parms p, int64_t reps)
{
pgc = xp->fggc;
- points = (XPoint *)malloc(p->objects * sizeof(XPoint));
+ points = malloc(p->objects * sizeof(XPoint));
for (int i = 0; i != p->objects; i++) {
points[i].x = 2 * (i/MAXROWS);
diff --git a/do_lines.c b/do_lines.c
index de9608d..1cead86 100644
--- a/do_lines.c
+++ b/do_lines.c
@@ -50,7 +50,7 @@ GenerateLines(XParms xp, Parms p, Bool ddashed)
size4 = 4 * (size+1);
half = (size + 19) / 20;
- points = (XPoint *)malloc((p->objects+1) * sizeof(XPoint));
+ points = malloc((p->objects+1) * sizeof(XPoint));
/* All this x, x1, x1inc, etc. stuff is to create a pattern that
(1) scans down the screen vertically
diff --git a/do_movewin.c b/do_movewin.c
index 05fb2ce..b7f0b44 100644
--- a/do_movewin.c
+++ b/do_movewin.c
@@ -42,8 +42,8 @@ InitMoveWindows(XParms xp, Parms p, int64_t reps)
y_offset = 0;
delta1 = 1;
- children = (Window *) malloc (p->objects*sizeof (Window));
- positions = (XPoint *) malloc(p->objects*sizeof(XPoint));
+ children = malloc(p->objects * sizeof (Window));
+ positions = malloc(p->objects * sizeof(XPoint));
xmax = (CHILDSIZE+CHILDSPACE) * (rows > 1 ? MAXCOLS : p->objects);
ymax = rows * (CHILDSIZE+CHILDSPACE);
@@ -105,7 +105,7 @@ DoResizeWindows(XParms xp, Parms p, int64_t reps)
int
InitCircWindows(XParms xp, Parms p, int64_t reps)
{
- children = (Window *) malloc (p->objects * sizeof (Window));
+ children = malloc (p->objects * sizeof (Window));
for (int i = 0; i != p->objects; i++) {
int pos = i % STACK;
int color = (i & 1 ? xp->foreground : xp->background);
@@ -145,8 +145,8 @@ InitMoveTree(XParms xp, Parms p, int64_t reps)
y_offset = 0;
delta1 = 1;
- children = (Window *) malloc (p->objects*sizeof (Window));
- positions = (XPoint *) malloc(p->objects*sizeof(XPoint));
+ children = malloc(p->objects * sizeof (Window));
+ positions = malloc(p->objects * sizeof(XPoint));
xmax = (CHILDSIZE+CHILDSPACE) * (rows > 1 ? MAXCOLS : p->objects);
ymax = rows * (CHILDSIZE+CHILDSPACE);
diff --git a/do_rects.c b/do_rects.c
index a3d1195..4c03d9c 100644
--- a/do_rects.c
+++ b/do_rects.c
@@ -47,7 +47,7 @@ InitRectangles(XParms xp, Parms p, int64_t reps)
lw = (lw >> 1) + 1;
}
- rects = (XRectangle *)malloc(p->objects * sizeof(XRectangle));
+ rects = malloc(p->objects * sizeof(XRectangle));
x = lw;
y = lw;
rows = 0;
diff --git a/do_segs.c b/do_segs.c
index 369f784..db1cd46 100644
--- a/do_segs.c
+++ b/do_segs.c
@@ -50,7 +50,7 @@ GenerateSegments(XParms xp, Parms p, Bool ddashed)
size8 = 8 * size;
half = (size + 19) / 20;
- segments = (XSegment *)malloc((p->objects) * sizeof(XSegment));
+ segments = malloc((p->objects) * sizeof(XSegment));
/* All this x, x1, etc. stuff is to create a pattern that
(1) scans down the screen vertically, with each new segment going
@@ -225,7 +225,7 @@ InitHorizSegments(XParms xp, Parms p, int64_t reps)
size = p->special;
half = (size + 19) / 20;
- segments = (XSegment *)malloc((p->objects) * sizeof(XSegment));
+ segments = malloc((p->objects) * sizeof(XSegment));
x = half;
y = half;
@@ -298,7 +298,7 @@ InitVertSegments(XParms xp, Parms p, int64_t reps)
size = p->special;
half = (size + 19) / 20;
- segments = (XSegment *)malloc((p->objects) * sizeof(XSegment));
+ segments = malloc((p->objects) * sizeof(XSegment));
x = half;
y = half;
diff --git a/do_text.c b/do_text.c
index 6ba8715..34947b9 100644
--- a/do_text.c
+++ b/do_text.c
@@ -72,14 +72,14 @@ InitText(XParms xp, Parms p, int64_t reps)
totalLines = '\177' - ' ' + 1;
if (totalLines > reps) totalLines = reps;
- charBuf = (char **) malloc(totalLines*sizeof (char *));
+ charBuf = malloc(totalLines * sizeof (char *));
if (p->special)
- items = (XTextItem *) malloc(totalLines*SEGS*sizeof (XTextItem));
+ items = malloc(totalLines * SEGS * sizeof (XTextItem));
for (int i = 0; i != totalLines; i++) {
char ch;
- charBuf[i] = (char *) malloc (sizeof (char)*charsPerLine);
+ charBuf[i] = malloc (sizeof (char) * charsPerLine);
ch = i + ' ';
for (int j = 0; j != charsPerLine; j++) {
charBuf[i][j] = ch;
@@ -169,23 +169,23 @@ InitText16(XParms xp, Parms p, int64_t reps)
charsPerLine = (charsPerLine + 3) & ~3; /* make a multiple of four */
p->objects = charsPerLine;
- items = (XTextItem *) malloc(totalLines*SEGS*sizeof (XTextItem));
+ items = malloc(totalLines * SEGS * sizeof (XTextItem));
for (int i = 0; i < totalLines; i++) {
char *pbuf0, *pbuf1, *pbuf2;
pbuf0 = items[i*SEGS+0].chars =
- (char *) malloc (sizeof (char)*charsPerLine/2);
+ malloc (sizeof (char) * charsPerLine/2);
items[i*SEGS+0].nchars = charsPerLine/4;
items[i*SEGS+0].delta = 0;
items[i*SEGS+0].font = font->fid;
pbuf1 = items[i*SEGS+1].chars =
- (char *) malloc (sizeof (char)*charsPerLine);
+ malloc (sizeof (char) * charsPerLine);
items[i*SEGS+1].nchars = charsPerLine/2;
items[i*SEGS+1].delta = 3;
items[i*SEGS+1].font = bfont->fid;
pbuf2 = items[i*SEGS+2].chars =
- (char *) malloc (sizeof (char)*charsPerLine/2);
+ malloc (sizeof (char) * charsPerLine/2);
items[i*SEGS+2].nchars = charsPerLine/4;
items[i*SEGS+2].delta = 3;
items[i*SEGS+2].font = font->fid;
@@ -204,10 +204,10 @@ InitText16(XParms xp, Parms p, int64_t reps)
}
}
} else {
- charBuf = (char **) malloc(totalLines*sizeof (char *));
+ charBuf = malloc(totalLines * sizeof (char *));
for (int i = 0; i < totalLines; i++) {
char *pbuf0 = charBuf[i] =
- (char *) malloc (sizeof (char)*charsPerLine*2);
+ malloc (sizeof (char) * charsPerLine * 2);
for (int j = 0; j < charsPerLine; j++) {
GetRealChar(font, totalChars, ch);
*pbuf0++ = ch / columns + font->min_byte1;
@@ -453,10 +453,10 @@ InitAAText(XParms xp, Parms p, int64_t reps)
totalLines = '\177' - ' ' + 1;
if (totalLines > reps) totalLines = reps;
- charBuf = (char **) malloc(totalLines*sizeof (char *));
+ charBuf = malloc(totalLines * sizeof (char *));
for (int i = 0; i != totalLines; i++) {
- charBuf[i] = (char *) malloc (sizeof (char)*charsPerLine);
+ charBuf[i] = malloc (sizeof (char) * charsPerLine);
ch = i + ' ';
for (int j = 0; j != charsPerLine; j++) {
charBuf[i][j] = ch;
diff --git a/do_traps.c b/do_traps.c
index b1b3e2b..0fd7056 100644
--- a/do_traps.c
+++ b/do_traps.c
@@ -41,7 +41,7 @@ InitTrapezoids(XParms xp, Parms p, int64_t reps)
size = p->special;
numPoints = (p->objects) * NUM_POINTS;
- points = (XPoint *)malloc(numPoints * sizeof(XPoint));
+ points = malloc(numPoints * sizeof(XPoint));
curPoint = points;
x = size;
y = 0;
@@ -136,7 +136,7 @@ InitFixedTraps(XParms xp, Parms p, int64_t reps)
size = p->special;
numTraps = p->objects;
- traps = (XTrap *)malloc(numTraps * sizeof(XTrap));
+ traps = malloc(numTraps * sizeof(XTrap));
curTrap = traps;
x = size;
y = 0;
@@ -273,7 +273,7 @@ InitFixedTrapezoids(XParms xp, Parms p, int64_t reps)
size = p->special;
numTraps = p->objects;
- trapezoids = (XTrapezoid *)malloc(numTraps * sizeof(XTrapezoid));
+ trapezoids = malloc(numTraps * sizeof(XTrapezoid));
curTrap = trapezoids;
x = size;
y = 0;
diff --git a/do_tris.c b/do_tris.c
index 6605fd1..1e1d3b9 100644
--- a/do_tris.c
+++ b/do_tris.c
@@ -91,7 +91,7 @@ InitTriangles(XParms xp, Parms p, int64_t reps)
iradius = (int) (radius + 0.5);
numPoints = (p->objects) * NUM_POINTS;
- points = (XPoint *)malloc(numPoints * sizeof(XPoint));
+ points = malloc(numPoints * sizeof(XPoint));
curPoint = points;
x = iradius;
y = iradius;
diff --git a/do_windows.c b/do_windows.c
index 386be6a..490b290 100644
--- a/do_windows.c
+++ b/do_windows.c
@@ -57,8 +57,8 @@ CreateParents(XParms xp, Parms p, int64_t reps)
/* We will do parentwindows sets of childwindows, in order to get better
timing accuracy. Creating 4 windows at a millisecond apiece or so
is a bit faster than the 60 Hz clock. */
- isolates = (Window *)malloc(parentwindows * sizeof(Window));
- parents = (Window *)malloc(parentwindows * sizeof(Window));
+ isolates = malloc(parentwindows * sizeof(Window));
+ parents = malloc(parentwindows * sizeof(Window));
/*
* Create isolation windows for the parents, and then the parents
diff --git a/x11perf.c b/x11perf.c
index 5adbc39..5782923 100644
--- a/x11perf.c
+++ b/x11perf.c
@@ -901,7 +901,7 @@ main(int argc, char *argv[])
/* Save away argv, argc, for usage to print out */
saveargc = argc;
- saveargv = (char **) malloc(argc * sizeof(char *));
+ saveargv = malloc(argc * sizeof(char *));
for (i = 0; i != argc; i++) {
saveargv[i] = argv[i];
}
@@ -912,7 +912,7 @@ main(int argc, char *argv[])
/* Count number of tests */
ForEachTest(numTests);
- doit = (Bool *)calloc(numTests, sizeof(Bool));
+ doit = calloc(numTests, sizeof(Bool));
/* Parse arguments */
program_name = argv[0];