Squashes:
shortest.c: In function ‘growtris’:
shortest.c:518:39: warning: conversion to ‘long unsigned int’ from ‘int’ may
change the sign of the result [-Wsign-conversion]
518 | tris = realloc(tris, TRIANGLESIZE * newtrin);
| ^
At the call site for `growtris`, it is not clear to me why `trin + 20` is
enough. That is, it seems like this branch can be hit, reallocation can succeed,
but `tril` was greater than `trin + 20` so the array remains too small for the
follow on computation. But this is a separate problem.
static int pnll;
static triangle_t *tris;
-static int trin, tril;
+static size_t trin;
+static int tril;
static deque_t dq;
static int pointintri(long, Ppoint_t *);
static int growpnls(size_t);
-static int growtris(int);
+static int growtris(size_t);
static int growdq(int);
static int growops(int);
int ei;
/* make space */
- if (tril >= trin) {
+ if (tril >= 0 && (size_t)tril >= trin) {
if (growtris(trin + 20) != 0)
return -1;
}
return 0;
}
-static int growtris(int newtrin)
-{
+static int growtris(size_t newtrin) {
tris = realloc(tris, TRIANGLESIZE * newtrin);
if (tris == NULL) {
prerror("cannot realloc tris");