PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ array_range()

static int array_range ( int  min,
int  max,
int  step,
int **  range,
int *  len 
)
static

Definition at line 93 of file raster2pgsql.c.

References rtalloc().

Referenced by main().

93  {
94  int i = 0;
95  int j = 0;
96 
97  step = abs(step);
98  *len = (abs(max - min) + 1 + (step / 2)) / step;
99  *range = rtalloc(sizeof(int) * *len);
100 
101  if (min < max) {
102  for (i = min, j = 0; i <= max; i += step, j++)
103  (*range)[j] = i;
104  }
105  else if (max < min) {
106  if (step > 0) step *= -1;
107  for (i = min, j = 0; i >= max; i += step, j++)
108  (*range)[j] = i;
109  }
110  else if (min == max) {
111  (*range)[0] = min;
112  }
113  else {
114  *len = 0;
115  *range = NULL;
116  return 0;
117  }
118 
119  return 1;
120 }
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition: rt_context.c:171
Here is the call graph for this function:
Here is the caller graph for this function: